Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8335951

Java fails to use ICC profiles from 3 of 6 color.org test images

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Windows 11 Pro
      openjdk version "21.0.1" 2023-10-17 LTS
      OpenJDK Runtime Environment Corretto-21.0.1.12.1 (build 21.0.1+12-LTS)
      OpenJDK 64-Bit Server VM Corretto-21.0.1.12.1 (build 21.0.1+12-LTS, mixed mode, sharing)


      A DESCRIPTION OF THE PROBLEM :
      color.org appears to be the official website of the International Color Consortium (the ICC). They have 6 test images with embedded color profiles as attachments.

      When Java reads these images it fails to parse & use the embedded ICC profiles for 3 out of 6.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Including a sample program to reproduce the issue. It fetches the 6 sample images, loads them one by one in Java, draws them to new images (whereby the color profile should have been applied in the drawing of each new image) , and saves the new images to an output directory.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Reviewing the images in the input and output directory shows that Java failed to handle the ICC profile embedded in browsertest.jpg, browsertest_lut.jpg, and Upper_Right.jpg

      browsertest.jpeg reads "This browser or workflow does NOT do any color management." when it should read "This browser or workflow claims to do v2 color management. it does work correctly onV2 profiles with both matrix and LUT."

      browsertest_lut.jpg reads "This browser or workflow does NOT support LUT-based input profiles." when it should read "This browser or workflow does support LUT-based input profiles"

      Upper_Right.jpg has the wrong colors when compared to the expected results on https://www.color.org/version4html.xalter

      ACTUAL -
      Included in the Expected result

      ---------- BEGIN SOURCE ----------
      import javax.imageio.ImageIO;
      import java.awt.*;
      import java.awt.image.BufferedImage;
      import java.io.File;
      import java.io.IOException;
      import java.nio.file.Paths;

      public class Main {

          static void test(String path) throws IOException {
              BufferedImage imgIn = ImageIO.read(Paths.get(path).toFile());
              BufferedImage imgOut = new BufferedImage(imgIn.getWidth(), imgIn.getHeight(), BufferedImage.TYPE_INT_ARGB);
              Graphics2D g = imgOut.createGraphics();
              g.drawImage(imgIn, 0, 0, null);
              g.dispose();
              File outfile = new File("out_"+path);
              System.out.println("tested "+path);
              ImageIO.write(imgOut, "png", outfile);
          }

          public static void main(String[] args) throws Exception {
              test("Lower_Right.jpg"); // v4 YCC-RGB - Not supported by Java
              test("Lower_Left.jpg");
              test("Upper_Right.jpg");
              test("Upper_Left.jpg");
              test("browsertest.jpg"); // Not supported by Java
              test("browsertest_lut.jpg"); // Not supported by Java
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      None found

      FREQUENCY : often


        1. browsertest_lut.jpg
          browsertest_lut.jpg
          106 kB
        2. browsertest.jpg
          browsertest.jpg
          117 kB
        3. Lower_Left.jpg
          Lower_Left.jpg
          43 kB
        4. Lower_Right.jpg
          Lower_Right.jpg
          42 kB
        5. Main.java
          1 kB
        6. Upper_Left.jpg
          Upper_Left.jpg
          30 kB
        7. Upper_Right.jpg
          Upper_Right.jpg
          27 kB

            jdv Jayathirth D V
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: