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

JPEG reader returns null for getRawImageType()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • client-libs
    • b105
    • generic

      If the included code is run with the attached "thumb.jpg" image as its input, then a RuntimeException is thrown at line 18. This contravenes the specification as getRawImageType() is supposed to return the first element of the Iterator returned by getImageTypes() which is specified to include at least one element.

      import java.io.File;
      import javax.imageio.ImageIO;
      import javax.imageio.ImageReader;
      import javax.imageio.ImageTypeSpecifier;
      import javax.imageio.stream.ImageInputStream;

      public class ReadDimensions {
          public static void main(String[] args) throws Throwable {
              File file = new File(args[0]);
              ImageInputStream in = ImageIO.createImageInputStream(file);
              ImageReader r = ImageIO.getImageReaders(in).next();
              r.setInput(in);
              int w = r.getWidth(0);
              int h = r.getHeight(0);
              System.out.println(file + ": " + w + " x " + h);
              ImageTypeSpecifier its = r.getRawImageType(0);
              if (its == null) {
                  throw new RuntimeException("ImageReader returns null raw image type"); // line 18
              }
          }
      }

            jdv Jayathirth D V
            bpb Brian Burkhalter
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: