Menu

#291 Problem JPEG file that works everywhere else

None
open
None
5
2019-04-11
2019-02-22
Vitaly
No

Please see the attached JPEG image. While displaying fine in most of viewers/browsers etc, we get wrong colors in FreeImage.

The problem is that it is missing some headers and heuristic is needed to process it properly. See here for more details: https://bugs.openjdk.java.net/browse/JDK-4845461

There is a sample implementation of the heuristic (note it is GPL so may not fit here): https://github.com/frohoff/jdk8u-jdk/blob/master/src/share/native/sun/awt/image/jpeg/imageioJPEG.c - look for saw_Adobe_marker keyword to see it.

I personally got it fixed with something like:

if (!cinfo.saw_JFIF_marker && cinfo.num_components == 3)
    cinfo.out_color_space = cinfo.jpeg_color_space;

right after jpeg_read_header() call in PluginJPEG.cpp and it works fine for both this file and my test set, but my set is relatively small and may not cover all the possible combinations of headers and data types.

A proper fix is highly appreciated.

1 Attachments

Discussion

  • Hervé Drolon

    Hervé Drolon - 2019-04-07
    • assigned_to: Hervé Drolon
    • Group: -->
     
  • Hervé Drolon

    Hervé Drolon - 2019-04-07

    Hi,

    I think your attached image was modified by SourceForge as nothing is wrong.
    Can you upload a new image inside a ZIP file (so that the upload process do not modify the file) ?

    Hervé

     
  • Vitaly

    Vitaly - 2019-04-11

    Sure, here you are. It seems that jpeglib 6 and 9 process this file differently and jpeg 6 works better. As we use 9 here, a workaround is needed.

     

Log in to post a comment.

MongoDB Logo MongoDB