Search code examples
javaimagejpeg

javaxt.io.Image doubles in size when using saveAs()


In an application, I need to use javaxt.io.Image to rotate the image and then save it into a new file. This is the code:

Image image = new Image(input);
image.rotate();
image.saveAs(output);

While the image does lose the EXIF rotation, which is the reason I needed this functionality, the image almost doubles in size. input.jpg is at 2.8MB, while output.jpg becomes 4.3MB. I couldn't find a parameter or function for compression in javaxt.io.Image.

Did I miss a step or is this behaviour wanted by the library? What would be the most efficient way to re-reduce the size?


Solution

  • As Thomas commented, I missed the function setOutputQuality(float quality) in the library documentation. Using that enables you to compress your images.