Closed k3rni closed 10 years ago
Also, for PDFs at least, page numbering doesn't have to start at 0. But that's not really important here.
I see. you're correct - it's not particularly supported yet because the imagemagick processors use a "convert" method under the covers which obscures the path argument and doesn't allow adding a number [n] I'll add this to the TODO list, or submit a pull request if you wish (though be warned I'm changing the processors fairly drastically in a branch soon be merged in)
was support ever added for this? Trying to resize only the first frame of an animated gif
this has been added in version 1 http://markevans.github.io/dragonfly/imagemagick/#processors
I saw. New version look great :)
The other thing I had added to dragonfly was a frame counter to analyzers to see if an image is animated. Not sure if you want to add this to the default analyzer but this is the code I added to count frames
# Counts frames to see if an image is animated
module Dragonfly
module ImageMagick
module Analysers
class ImageAnimated
def call(content)
identify_command = content.env[:identify_command] || 'identify'
details = content.shell_eval do |path|
"#{identify_command} -format '%n' #{path}"
end
details.scan(/\d/).join('').to_i > 1
end
end
end
end
end
cool! good to see the new custom analyser stuff getting used. I won't add it by default if you don't mind, as I'm trying to keep the codebase small and let users do their own processors/analysers as much as possible. by the way there's also a method "identify" (not an analyser) and a configuration option "define" so if you don't need it to be an analyser, you can just do this now in the config:
define :image_animated? do
identify("-format %n").to_i > 1
end
:+1: nicely done.
Frames (as in a GIF, MNG animation or a PS, PDF file with multiple pages) are selected using a subscript notation (see http://www.imagemagick.org/script/command-line-processing.php, under "Selecting Frames"). When not selected, IM either keeps the multiple-image format, or produces multiple separate files.
Dragonfly currently doesn't offer an option to choose which frame I want to work on.
Examples:
creates
outputfile
as a multipage pdf, each page scaled down appropriatelyproduces as many files named
outputfile-%d.png
as there were pagescreates a single-page pdf, scaled down
creates a single png file, with the desired thumbnail
The last option is what I'm after, such as:
Dragonfly[:app].fetch(UID).convert('-thumbnail 100x100', :frame => 0).png
orDragonfly[:app].fetch(UID).thumb('100x100', :frame => 0).png
Or have I missed something in the docs?