'Java Image orientation transfers from Landscape to Portrait ImageIO.read()
when the image is loaded from localdrive by default my image rotates to Portrait from Landscape. My image type is ".jpg" and size is 1.32MB. To verify the issue I have just write the image to output directory after immediate read. I suspect this is happening due to filesize of input image ? Because when the file size is small, orientation is not changing. I need to keep the image in Landscape in order to split the image into 2 parts.
InputStream inputStream= new FileInputStream("d:/dev/test/xxxxxx.jpg");
BufferedImage image = ImageIO.read(inputStream);
File outputfile = new File("image.jpg");
ImageIO.write(image, "jpg", outputfile);
Please suggest me a better solution and why BufferedImage converts the orientation from Lnadscape to Portrait? If the reading of image as it is with orientation is not possible, how to transfer the image back to Landscape?
For work around I have resized the input image and retried the orientation is not changed. Thank again.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|