[Melbourne-pm] Image::Resize, avidemux and JPEG types

Leigh Sharpe leigh.sharpe at gmail.com
Sat Feb 9 16:45:33 PST 2013


Hi All,
  I've been using Image::Resize for a while, and it works a treat. But 
recently I've found that if I use avidemux to save a screenshot from a 
video as a JPEG, Image::Resize chokes on it.
  The offending code is in this block in GD::Image :

sub _image_type {
   my $data = shift;
   my $magic = substr($data,0,4);
   return 'Png'  if $magic eq "\x89PNG";
   return 'Jpeg' if $magic eq "\377\330\377\340";
   return 'Jpeg' if $magic eq "\377\330\377\341";
   return 'Jpeg' if $magic eq "\377\330\377\355";
   return 'Jpeg' if $magic eq "\377\330\377\356";
   return 'Gif'  if $magic eq "GIF8";
   return 'Gd2'  if $magic eq "gd2\000";
   return 'Xpm'  if substr($data,0,9) eq "/* XPM */";
   return;
}


...It turns out that my images all start with   \377\330\377\376

The fix is as simple as adding another line to the sub above, to say:


   return 'Jpeg' if $magic eq "\377\330\377\376";


..But I'm not sure just where the fault lies here. Should I submit a 
patch to the GD::Image maintainers? Or is this actually a bug in 
avidemux? Is the image being created by avidemux actually valid?

Any ideas??




More information about the Melbourne-pm mailing list