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

Free Support Forum - groupdocs.com

Image file is being converted with left rotation

Hi,
using conversion lib 21.10.1.
I’m trying to convert this jpg file: 20220223_143713.jpg (965.6 KB)
to a png file. But I get this output file: 20220223_1437131.jpg (1.9 MB)
(Your support system converted the file to jpg because png file was exceeding max upload size).

The file is being rotated left for some reason.
Can you help?

@nirm

We tried to convert the provided JPG to PNG using following Java code and the output has the same orientation as the source file.

//Java code
//Specify output folder
String outputFolder = "D:/";
String outputFileTemplate = new File(outputFolder, "converted-page-%d.png").getPath();
try (FileOutputStream getPageStream = new FileOutputStream(String.format(outputFileTemplate, 1))) {
     //pass the JPG to Converter class
     Converter converter = new Converter("D:/20220223_143713.jpg"); 
     ImageConvertOptions options = new ImageConvertOptions();
     //specify the output image type
     options.setFormat(ImageFileType.Png);
     options.setPagesCount(1); 
     converter.convert(getPageStream, options);
} catch (IOException e) {
     System.out.println(e.getMessage());
}

Please have a look at this output.
Could you please share the sample application/code?

I’m using the same code. I compared your output to my output file and I see that the dimensions are were switched, meaning that your output file has a 3024 X 5376 resolution and mine is 5376 X 3024 which makes it horizontal or something like that. Can you think of something that I’m doing wrong, or didn’t do?

UPDATE:
Please review this screenshot from my conversion process: screenshot.jpg (44.4 KB)
What is the reason that the documentInfo is reading the file wrong?
You can see that it reads the height as 2268 and width 4032, while it actually the opposite.
I’m assuming this is what causing the rotate on the output image.
Why does it happen?

Another update: I used your code as is, and the output file is still rotated to the left.

1 Like

@nirm

Yes, at our end the height is 4032 and the width is 2268. However, in order to further look into this issue, we need following details:

  • Sample console application
  • Development environment details (e.g. OS, Java version)

The code is exactly the code you posted here.
This happens in both Windows 10 Pro and Ubuntu 20, both in Java 11 OpenJDK.
Can we do a Zoom or something?

I’m guessing the orientation on the output happens because input image has an
orientation value = “Right top”. Can you eliminate that before the conversion? Or change it to be normal?
I added a screenshot to show it: proof.jpg (230.8 KB)
The original input image was taken from an IPhone 12 if it matters.

1 Like

@nirm

I am afraid but all free support issues are assisted on this forum.

We still cannot reproduce this issue at our end. However, as a workaround, please try to set the rotation angle as follows:

ImageConvertOptions options = new ImageConvertOptions();
//set rotation angle
options.setRotateAngle(360);

You can set rotation angle to any value. 360 worked at our end. Let us know if you get the right output.

I don’t understand, I’m a paid customer, I paid almost 3,600 USD to you. Do I not deserve a basic Zoom call?
I want to show you a quick demo on my machine.

@nirm

As per the free support policy, all issues have to be addressed on forum. Please record a video and explain/share the steps using that issue could be reproduced.

I’ll do that right now.
And the rotation(360) didn’t work.
Thank you

Hi @Atir_Tahir,
Thank you upfront for the personal care.
I recorded a video of the conversion process.
Here’s my environment: Windows 10 Pro, Java Amazon Corretto 11 (based on OpenJDK), Intellij IDEA Ultimate 2021.1.3.
Here’s the video (via my Google Drive): https://drive.google.com/file/d/18im_Fzgw58BlgVNdsvwWU63PMYspUOna/view?usp=sharing

Thank you, waiting for your feedback

1 Like

@nirm

We appreciate your cooperation. We’ve logged this scenario in our internal issue tracking system with ID CONVERSIONJAVA-1598. It’ll be now further investigated. You’ll be notified in case of any update.

Hi, any updates??

@nirm

We are still investigating this issue.

Hi @Atir_Tahir ,
I saw that you have a product called GroupDocs.MetaData that reads metadata out of input files.
I think the problem here in my case, is that your conversion code doesn’t read the EXIF metadata file out of the input jpg file. That’s why it doesn’t recognize the orientation value (written in the EXIF) and it converts the image with the oriented value instead of keeping the image straight.
Can you check this please?

@nirm

We are still investigating this scenario. However, we’ll notify you in case of any update.