ParametricPress / 01-unraveling-the-jpeg

Source code for Unraveling the JPEG
https://parametric.press/issue-01/unraveling-the-jpeg/
MIT License
246 stars 21 forks source link

Ignore JPEG Thumbnails #1

Open OmarShehata opened 5 years ago

OmarShehata commented 5 years ago

The JPEG byte editor we've got will extract the header, remove it, and allow you to edit just the body. We do this by checking for the SOS (start of scan) marker, which is FFDA or 255 218.

But if the JPEG contains a thumbnail, there will be two SOS markers, since the stored thumbnail is itself another JPEG image. This will incorrectly append another body, so it leads to a lot of extra bytes that don't change the image at all.

We can get around this by just having all our sample JPEGs not include a thumbnail, but to make it work for any user supplied JPEG this would be nice to do.