Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-browser incompatibilities in decoding JPEG files?

Something is puzzling me - why does this image appear different in every browser?

Image in IE9 (and Windows Photo Viewer):
Image in IE9

Image in Firefox (and Photoshop):
Image in Firefox

Image in Chrome (and Irfanview):
Image in Chrome

What is going on in their decoding processes of the JPEG to make the eventual output so different?

(View it in IE, Firefox, Chrome, etc. to see what I mean.)

like image 665
Isaac Zigzag Avatar asked Oct 14 '10 21:10

Isaac Zigzag


3 Answers

JPEGSnoop (source now available @ sourceforge) reports large luma overflow before we even get to Y'CbCr to RGB conversion. I get these errors on some other files, but the overflow is typically small- 256 or 257 vs. a max of 255. The luma calculated here is 729!

JPEGSnoop's author's comments on YCC overflow:

YCC clipping in DC - Each MCU adds or subtracts from the DC (average) value in the previous MCU. These should all stay within an 8-bit range, but corruption in the DC coefficient may cause this value to wander out of range. This type of error will cause sudden large-scale changes in color or brightness in your image. As this type of error generally won't recover, JPEGsnoop will only report the first 10 of these in the log file.

I wasn't familiar with the inter-MCU DC, but Pennebaker & Mitchel concur.

*** Decoding SCAN Data ***
  OFFSET: 0x00000160
  Scan Decode Mode: Full IDCT (AC + DC)

  Scan Data encountered marker   0xFFD9 @ 0x00027CA9.0

*** NOTE: YCC Clipped. MCU=(   0,   0) YCC=(  729,  109,  171) Y Overflow @ Offset 0x00027CA8.2
*** NOTE: YCC Clipped. MCU=(   0,   0) YCC=(  682,  109,  172) Y Overflow @ Offset 0x00027CA8.2
*** NOTE: YCC Clipped. MCU=(   0,   0) YCC=(  741,  109,  173) Y Overflow @ Offset 0x00027CA8.2
*** NOTE: YCC Clipped. MCU=(   0,   0) YCC=(  629,  109,  174) Y Overflow @ Offset 0x00027CA8.2
*** NOTE: YCC Clipped. MCU=(   0,   0) YCC=(  841,  109,  175) Y Overflow @ Offset 0x00027CA8.2
*** NOTE: YCC Clipped. MCU=(   0,   0) YCC=(  319,  109,  176) Y Overflow @ Offset 0x00027CA8.2
*** NOTE: YCC Clipped. MCU=(   0,   0) YCC=(  928,  109,  177) Y Overflow @ Offset 0x00027CA8.2
*** NOTE: YCC Clipped. MCU=(   0,   0) YCC=(  624,  109,  177) Y Overflow @ Offset 0x00027CA8.2
*** NOTE: YCC Clipped. MCU=(   1,   0) YCC=(  785,  107,  171) Y Overflow @ Offset 0x00027CA8.2
*** NOTE: YCC Clipped. MCU=(   1,   0) YCC=(  559,  107,  171) Y Overflow @ Offset 0x00027CA8.2
    Only reported first 10 instances of this message...
like image 199
Morgan W. Avatar answered Nov 04 '22 08:11

Morgan W.


JPEG can be encoded in RGB or CMYK. These nicities usually occur when it's CMYK. Open the file in an image editing program and save it as RGB JPEG, and salute the CMYK printers, which will now have the different results you previously had in the browser.

like image 26
Stefan Steiger Avatar answered Nov 04 '22 06:11

Stefan Steiger


I'm only guessing.
If the image was created to show these differences perhaps it's not a normal image which was encoded, but an invalid one where the calculated colors are outside of the 0 to 255 range and different decoders handle these differently.

like image 1
CodesInChaos Avatar answered Nov 04 '22 08:11

CodesInChaos