I have been using CarrierWave for file uploads on a site which needs to accept a really wide range of different movie formats, stills, PDFs... And I have been struggling with making thumbnails of certain formats. After much yak-shaving with ffmpeg and imagemagick and Rmagick, I finally decided to do a little spike app with nothing but Paperclip. I set up the simplest thing that could possibly work: has_attached_file :blob, :styles => { :thumb => ["320x320>", :png], :large => ["1500x1500>", :png] } And no matter what format (within reason) I pass to it, I get a nicely formed PNG format thumbnail and large preview image. PSD, PDF, TIFF, MOV, M4V -- it Just Works™. And I cannot figure out how it is doing this, despite reading through the source code for quite a while. The reason why I need to access the magic is that while I am getting a nice thumbnail from any movie format I pass in, I am getting the very first frame of the movie (usually black) rather than a few seconds into the clip. In my CarrierWave converter, I had a custom offset time defined for this. But I cannot see where Paperclip is defining what to do with a video to generate a PNG image so I can alter this default. There are tons of examples on SO and the Web in general, showing how to create a custom video thumbnailer and transcoder, but I would like to avoid rebuilding this wheel that Paperclip seems to have hewn out of pure Elven magick. Thanks in advance, Walter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/87E1CB56-F23E-4EF2-A760-9F6D6A2C0B74%40wdstudio.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
I haven''t seen the paperclip code but I think you can look at the preprocessors used by default by paperclip. You usually see logs when paperclip does some processing using rmagick which may be a clue as to what part of the lib you want to look at. On Wed, Jun 12, 2013 at 11:15 PM, Walter Lee Davis <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org>wrote:> I have been using CarrierWave for file uploads on a site which needs to > accept a really wide range of different movie formats, stills, PDFs... And > I have been struggling with making thumbnails of certain formats. After > much yak-shaving with ffmpeg and imagemagick and Rmagick, I finally decided > to do a little spike app with nothing but Paperclip. I set up the simplest > thing that could possibly work: > > has_attached_file :blob, :styles => { :thumb => ["320x320>", :png], :large > => ["1500x1500>", :png] } > > And no matter what format (within reason) I pass to it, I get a nicely > formed PNG format thumbnail and large preview image. PSD, PDF, TIFF, MOV, > M4V -- it Just Works™. And I cannot figure out how it is doing this, > despite reading through the source code for quite a while. > > The reason why I need to access the magic is that while I am getting a > nice thumbnail from any movie format I pass in, I am getting the very first > frame of the movie (usually black) rather than a few seconds into the clip. > In my CarrierWave converter, I had a custom offset time defined for this. > But I cannot see where Paperclip is defining what to do with a video to > generate a PNG image so I can alter this default. > > There are tons of examples on SO and the Web in general, showing how to > create a custom video thumbnailer and transcoder, but I would like to avoid > rebuilding this wheel that Paperclip seems to have hewn out of pure Elven > magick. > > Thanks in advance, > > Walter > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/87E1CB56-F23E-4EF2-A760-9F6D6A2C0B74%40wdstudio.com?hl=en-US > . > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJ8y7Vdt3BKPzFd%2BzQDsLnNA2G0%2BY2d0pa9fc4RQFVVH6kLuhA%40mail.gmail.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Jason Fleetwood-Boldt
2013-Jun-12 16:21 UTC
Re: Paperclip thumbnail generation uses magic?
you may want to put this into something that loads when you app loads, like initializers/paperclip.rb Paperclip.options[:log] = true On Jun 12, 2013, at 11:58 AM, Jim Ruther Nill wrote:> I haven''t seen the paperclip code but I think you can look at the preprocessors used by default by paperclip. > You usually see logs when paperclip does some processing using rmagick which may be a clue as to what > part of the lib you want to look at. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CA4BAB47-745B-4FDE-A670-AF7FA18824CE%40datatravels.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Thanks, that''s good advice. The console told the tale. It appears as though ImageMagick is delegating to ffmpeg, and the convert function that Paperclip generates in their thumbnail operation tacks a [0] to the end of the filename to get it to use the first frame. I need to do some more digging, but it appears as though I can just put a different number in there for movies. It seems as though all file types are getting the [0] treatment, not just movies, so I don''t want to start looking for frame 10 in a TIFF... Walter On Jun 12, 2013, at 11:58 AM, Jim Ruther Nill wrote:> I haven''t seen the paperclip code but I think you can look at the preprocessors used by default by paperclip. > You usually see logs when paperclip does some processing using rmagick which may be a clue as to what > part of the lib you want to look at. > > > On Wed, Jun 12, 2013 at 11:15 PM, Walter Lee Davis <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: > I have been using CarrierWave for file uploads on a site which needs to accept a really wide range of different movie formats, stills, PDFs... And I have been struggling with making thumbnails of certain formats. After much yak-shaving with ffmpeg and imagemagick and Rmagick, I finally decided to do a little spike app with nothing but Paperclip. I set up the simplest thing that could possibly work: > > has_attached_file :blob, :styles => { :thumb => ["320x320>", :png], :large => ["1500x1500>", :png] } > > And no matter what format (within reason) I pass to it, I get a nicely formed PNG format thumbnail and large preview image. PSD, PDF, TIFF, MOV, M4V -- it Just Works™. And I cannot figure out how it is doing this, despite reading through the source code for quite a while. > > The reason why I need to access the magic is that while I am getting a nice thumbnail from any movie format I pass in, I am getting the very first frame of the movie (usually black) rather than a few seconds into the clip. In my CarrierWave converter, I had a custom offset time defined for this. But I cannot see where Paperclip is defining what to do with a video to generate a PNG image so I can alter this default. > > There are tons of examples on SO and the Web in general, showing how to create a custom video thumbnailer and transcoder, but I would like to avoid rebuilding this wheel that Paperclip seems to have hewn out of pure Elven magick. > > Thanks in advance, > > Walter > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/87E1CB56-F23E-4EF2-A760-9F6D6A2C0B74%40wdstudio.com?hl=en-US. > For more options, visit https://groups.google.com/groups/opt_out. > > > > > > -- > ------------------------------------------------------------- > visit my blog at http://jimlabs.heroku.com > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAJ8y7Vdt3BKPzFd%2BzQDsLnNA2G0%2BY2d0pa9fc4RQFVVH6kLuhA%40mail.gmail.com?hl=en-US. > For more options, visit https://groups.google.com/groups/opt_out. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/F6D83DD0-F831-4DDA-B86C-CA75191911B2%40wdstudio.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.