I’m using Waffle (a fork of Arc) for image uploads in my Phoenix project. When an image is successfully uploaded, I would like to generate a bunch of smaller images from it, which will then be used in a tiled image pyramid viewer. Of course if the user deletes the image the tiles should be automatically deleted as well.
How can I accomplish this?
If I understand it correctly, Arc’s default “transformations” flow assumes each input file may map to at most one output file for each version, even if I want to run arbitrary commands. I already have the command to generate the images, I just need to understand how to integrate this with Arc.
It is possible to specify multiple versions in the uploader, something like…
@versions [:original, :large, :thumb, :mini]
def transform(:mini, _) do
{:convert, "-resize 160x90^ -gravity center -extent 160x90 -format png", :png}
end
def transform(:thumb, _) do
...
end
def transform(:large, _) do
...
end
For delete, I did not solve it yet in the best way… In case of cascade delete for example…
But I have a cleaning task running periodically, deleting what needs to be.
Sorry, I’m not sure I was clear enough. I know I can define these versions, but each version is assumed to only produce one file, right?
I’m implementing an image viewer that allows users to pan and zoom very large images. For this I need to generate an arbitrary number of files based on the dimensions of the input image. More specifically, from a single image I must produce many “slices” (cropped and resized squares) that correspond to x, y and z coordinates (z for zoom). This is common practice for “image pyramids”, “slippy maps”, etc. (if you want to look up those terms). So I don’t know how many images will be produced, and I don’t want to refer to each of them by name, but by “coordinate”. For instance, /uploads/myimg/0/2/3.jpg would be x=0, y=2, z=3. So I imagine it being a single version (e.g. :slices) with 3 parameters (x, y and z).
I have also used transformation tools with System.cmd…
Just I did not use waffle transform, but a custom job. I used ffmpeg, to capture screen from video, but it was too heavy for waffle (taking too long). I did a custom background job in that case.
If You have a file location, You can apply anything on it… with imagemagick convert, or ffmpeg, or any other tools.
Would you mind explaining how you did this background job?
And do you think it would be possible to run the command and make transform return the path to a folder that contains all generated images for the input file, rather than return the path to a single file? Then I’d be able to do something like: <img src="<%= Pyramid.url({"myimg.png", img}, :slices) %>/0/0/0.jpg">
I’m still very much a newbie so I’m still pretty lost, but I’ll try to understand things a little better before asking more questions. Thank you very much!