You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically i have a generic uploader, which handles uploads of images, videos, and audio files.
I case that the file type is not a image, i don't want to create a thumbnails, as thumbnails of a audio file don't really makes sense.
I currently just reply with :noreply if that is the case, but this will make 3 copys of the same file. Is it somehow possible to disregard transform if a condition is not met?
This is my current code, making 3x videos/audio files.
# Define a thumbnail transformation:deftransform(:thumb,{file,_})doifEnum.member?(~w(.jpg .jpeg .gif .png),Path.extname(file.file_name))do{:convert,"-strip -thumbnail 150x150 -gravity center -format png",:png}else:noactionendend# Define a thumbnail transformation:deftransform(:thumb_small,{file,_})doifEnum.member?(~w(.jpg .jpeg .gif .png),Path.extname(file.file_name))do{:convert,"-strip -thumbnail 20x20 -gravity center -format png",:png}else:noactionendend
The text was updated successfully, but these errors were encountered:
It doesn't work because you assume you already have the file, but you don't.
transform function is invoked before the file is in the upload folder
Try this and you would understand:
def transform(:original, _) do
{:convert, fn(input, output) ->
IO.inspect input
IO.inspect output
"#{input} #{output}" end, :jpg}
end
Although it doesn't mean you can't
Try this: def transform(:original, toLog) do IO.inspect toLog {:convert, fn(input, output) -> "#{input} #{output}" end, :jpg} end
Basically i have a generic uploader, which handles uploads of images, videos, and audio files.
I case that the file type is not a image, i don't want to create a thumbnails, as thumbnails of a audio file don't really makes sense.
I currently just reply with :noreply if that is the case, but this will make 3 copys of the same file. Is it somehow possible to disregard transform if a condition is not met?
This is my current code, making 3x videos/audio files.
The text was updated successfully, but these errors were encountered: