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

David Warring david.warring at gmail.com
Tue Feb 12 16:44:33 PST 2013


I've found this thread on SO
http://stackoverflow.com/questions/1557071/the-size-of-a-jpegjfif-image.

It seems to concur with what Andrew is saying. The accepted answer
references http://www.w3.org/Graphics/JPEG/itu-t81.pdf p.32.

If I'm following this correctly,  bytes 3 and 4 represent a segment header.
Byte 3 is always \377. but byte 4 can take a range of values; which agrees
with just not checking the 4th byte.

- David





On Sun, Feb 10, 2013 at 12:07 PM, Andrew McN <andrewmcnnz at gmail.com> wrote:

> Googling this suggests that many other file recognition systems match on
> "\377\330\377" and don't care about the next byte.
>
> Not sure if it's recommended. Haven't found an authoritative reference.
> On 10/02/2013 11:45 AM, "Leigh Sharpe" <leigh.sharpe at gmail.com> wrote:
>
>> 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??
>>
>>
>> ______________________________**_________________
>> Melbourne-pm mailing list
>> Melbourne-pm at pm.org
>> http://mail.pm.org/mailman/**listinfo/melbourne-pm<http://mail.pm.org/mailman/listinfo/melbourne-pm>
>>
>
> _______________________________________________
> Melbourne-pm mailing list
> Melbourne-pm at pm.org
> http://mail.pm.org/mailman/listinfo/melbourne-pm
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20130213/33b38dff/attachment-0001.html>


More information about the Melbourne-pm mailing list