We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

JpegImage.autoRotate() throws Exception on some Jpeg images

Exception thrown:

class com.aspose.imaging.internal.Exceptions.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

2015-06-22 17.36.00.jpg (182.0 KB)
Leicester_Clock_Tower_wide_view.jpg (324.1 KB)

@thomas.winklehner,

I have observed the issue shared by you and request you to please share the working sample code reproducing the issue on your end. I also suggest you to please try using Aspose.Imaging for Java 17.12 as well on your end first before sharing information with us.

Aspose.Imaging version used: 17.12

Code:

Image image = Image.load(inputStream);

if (image.getFileFormat() == FileFormat.Jpeg)
    ((JpegImage) image).autoRotate();
                                
image.save(out, new PngOptions());

@thomas.winklehner,

I have worked with JPEG image files shared by you using Aspose.Imaging for Java 17.12 on my end in Windows 7 x64 with JDK 1.7_79 on my end. I have not been able to observe any issue while loading and saving the JPEG files. I have used following sample code and for your convenience, I have shared the saved images as well.

public static void LoadJpeg()
{
    String path="C:\\Imaging Data\\Pics\\";
  //Image image = Image.load(path+"2015-06-22 17.36.00.jpg");
  // Load the image in an instance of JpegImage
  JpegImage image = (JpegImage) Image.load(path + "2015-06-22 17.36.00.jpg");
  if (image.getFileFormat() == FileFormat.Jpeg)
      image.autoRotate();

  image.save(path+"2015-06-22 17.36.00_saved.jpeg", new PngOptions());   
}

[Saved Images](https:// drive.google.com/file/d/1YcCaZsEs2MTkpvyDwrWis4gtM5qpH0bt/view)