Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto_rotate doesn't work as expected. Processed image is wrongly rotated. #1311

Closed
gencer opened this issue May 19, 2019 · 4 comments
Closed
Labels

Comments

@gencer
Copy link

gencer commented May 19, 2019

I am trying to process an image taken by specifically S9+. Image looks normal on Windows. I transfer that image to Linux (Debian) and process via ruby. Output is always 90-degree rotated. It should rotate correctly same as input. :autorotate key didn't help.

Sample Image: 20190519_225024.zip

Sample has vertically usb stick. Output is always horizontally.

Please also see our discussion here: janko/image_processing#52

However, I ran the same script on Windows with libvips 8.6.4, output is correct. I get correct rotation. Same as input.

I also did one last test. Ran the script in Linux then copy output file to windows and I see that they are rotated wrongly.

Linux server has libvips 8.7.4. Also installed 8.8.0-rc3 recently. Both has the same behavior.

Also, @janko confirms that it works on Mac too.

What might be the problem?

I was woking on Golang previously, when i upload and process such images (like the attached one) i always get the correct result with :autorotate. But not this time on ruby

Script:

require "vips"

file_path = "./20190518_094223.jpeg"

Vips::Image
  .new_from_file(file_path, autorotate: true)
  .write_to_file("autorotated_1.png")

Vips::Image
  .new_from_file(file_path)
  .autorot
  .write_to_file("autorotated_2.png")

Vips::Image
  .jpegload(file_path, autorotate: true)
  .write_to_file("autorotated_3.png")

Vips::Image
  .thumbnail(file_path, size, height: size)
  .write_to_file("autorotated_4.png")

Vips::Image
  .thumbnail(file_path, size, height: size, auto_rotate: true)
  .write_to_file("autorotated_5.png")

Update:

I open that image with mspaint, draw a line randomly. Saved it. Then processed with above script and output is correct. This is really weird.

@gencer gencer changed the title auto_rotate doesn't work as expected auto_rotate doesn't work as expected. Processed image is wrongly rotated. May 19, 2019
@jcupitt
Copy link
Member

jcupitt commented May 19, 2019

Hello @gencer,

Just a guess, but could your libvips on Debian have been built without libexif?

Without exif support, libvips will unable to see the orientation tag on the image and will not rotate it.

@jcupitt
Copy link
Member

jcupitt commented May 19, 2019

To test, try reading the orientation tag at the command-line, eg.

$ vipsheader -f orientation ~/pics/Portrait_6.jpg 
6

@gencer
Copy link
Author

gencer commented May 19, 2019

Since I see your answer, i can't stop laughing to myself. How did I missed that!

Yes, libexif-dev is not installed on the machine...

Issue resolved by rebuilding with libexif-dev.

(Seriously, 😒 how did i missed that)

Thank you!

@jcupitt
Copy link
Member

jcupitt commented May 20, 2019

Glad it's working now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants