<div dir="ltr">I've found this thread on SO <a href="http://stackoverflow.com/questions/1557071/the-size-of-a-jpegjfif-image">http://stackoverflow.com/questions/1557071/the-size-of-a-jpegjfif-image</a>. <div><br></div>
<div>It seems to concur with what Andrew is saying. The accepted answer references <a href="http://www.w3.org/Graphics/JPEG/itu-t81.pdf">http://www.w3.org/Graphics/JPEG/itu-t81.pdf</a> p.32.<div><br></div><div style>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.</div>
<div style><br></div><div style>- David</div><div style><br></div><div style><br></div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Feb 10, 2013 at 12:07 PM, Andrew McN <span dir="ltr"><<a href="mailto:andrewmcnnz@gmail.com" target="_blank">andrewmcnnz@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Googling this suggests that many other file recognition systems match on "\377\330\377" and don't care about the next byte. </p>

<p dir="ltr">Not sure if it's recommended. Haven't found an authoritative reference. </p><div class="HOEnZb"><div class="h5">
<div class="gmail_quote">On 10/02/2013 11:45 AM, "Leigh Sharpe" <<a href="mailto:leigh.sharpe@gmail.com" target="_blank">leigh.sharpe@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi All,<br>
 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.<br>
 The offending code is in this block in GD::Image :<br>
<br>
sub _image_type {<br>
  my $data = shift;<br>
  my $magic = substr($data,0,4);<br>
  return 'Png'  if $magic eq "\x89PNG";<br>
  return 'Jpeg' if $magic eq "\377\330\377\340";<br>
  return 'Jpeg' if $magic eq "\377\330\377\341";<br>
  return 'Jpeg' if $magic eq "\377\330\377\355";<br>
  return 'Jpeg' if $magic eq "\377\330\377\356";<br>
  return 'Gif'  if $magic eq "GIF8";<br>
  return 'Gd2'  if $magic eq "gd2\000";<br>
  return 'Xpm'  if substr($data,0,9) eq "/* XPM */";<br>
  return;<br>
}<br>
<br>
<br>
...It turns out that my images all start with   \377\330\377\376<br>
<br>
The fix is as simple as adding another line to the sub above, to say:<br>
<br>
<br>
  return 'Jpeg' if $magic eq "\377\330\377\376";<br>
<br>
<br>
..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?<br>
<br>
Any ideas??<br>
<br>
<br>
______________________________<u></u>_________________<br>
Melbourne-pm mailing list<br>
<a href="mailto:Melbourne-pm@pm.org" target="_blank">Melbourne-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/melbourne-pm" target="_blank">http://mail.pm.org/mailman/<u></u>listinfo/melbourne-pm</a><br>
</blockquote></div>
</div></div><br>_______________________________________________<br>
Melbourne-pm mailing list<br>
<a href="mailto:Melbourne-pm@pm.org">Melbourne-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/melbourne-pm" target="_blank">http://mail.pm.org/mailman/listinfo/melbourne-pm</a><br></blockquote></div><br></div>