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

BufferedImages (TYPE_INT_ARGB) can't be saved as jpg with ImageIO

    Details

    • Subcomponent:
    • Introduced In Version:
      11
    • CPU:
      x86_64
    • OS:
      windows_7

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      >java -version
      java version "11" 2018-09-25
      Java(TM) SE Runtime Environment 18.9 (build 11+28)
      Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11+28, mixed mode)

      A DESCRIPTION OF THE PROBLEM :
      BufferedImages of TYPE_INT_ARGB can't be saved as jpg with ImageIO.

      REGRESSION : Last worked in version 10.0.2

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      run the code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      com.sun.imageio.plugins.jpeg.JPEGImageWriter@464bee09
      result: true
      ACTUAL -
      com.sun.imageio.plugins.jpeg.JPEGImageWriter@464bee09
      result: false

      ---------- BEGIN SOURCE ----------
      import java.awt.image.BufferedImage;
      import java.io.ByteArrayOutputStream;
      import java.io.IOException;
      import javax.imageio.ImageIO;


      public class jdk11test
      {
          public static void main(String[] args) throws IOException
          {
              System.out.println(ImageIO.getImageWritersByFormatName("jpg").next());
              BufferedImage bim = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
              boolean res = ImageIO.write(bim, "jpg", new ByteArrayOutputStream());
              System.out.println("result: " + res);
          }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      use jdk10 or earlier; or use TYPE_INT_RGB; or save as png instead of jpg.

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              kaddepalli Krishna Addepalli
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: