Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Changing image orientation while saving to file

f6df8302-abef-455f-9673-7dcd611acd52Jul 30 2014 — edited Jul 30 2014

I get a Base64Encoded image string (GIF format) from an external system. While reading the byte array and saving the image to file, the image gets saved in landscape orientation.

The code snippet is below.

String image = "R0lGODdhCAcgA=";

Base64Coder decoder = new Base64Coder();

byte [] decodeBytes = decoder.decode(image.getBytes());

ByteArrayInputStream stream = new ByteArrayInputStream(pngArray);

BufferedImage bImage = ImageIO.read(stream);

File label = new File("C:/labels/test.gif");

ImageIO.write(bImage, "gif", label);

I want to save the image in portrait orientation. Is there a way to do that?

Comments

EJP

This isn't clear. Is the image already in the orientation you want?

unknown-7404

Looks like ImageIO doesn't support that but third party libraries do.

See if you can use the solution in this thread:

java - Is javax.imageio.ImageIO broken? It imports some images as rotated - Stack Overflow

1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Aug 27 2014
Added on Jul 30 2014
2 comments
1,087 views