Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::image can't detect Windows image rotation for JPEG files  (Read 2431 times)

0 Members and 1 Guest are viewing this topic.

guyyst

  • Newbie
  • *
  • Posts: 5
    • View Profile
sf::image can't detect Windows image rotation for JPEG files
« on: February 25, 2016, 07:44:09 pm »
When I rotate an image using the Windows explorer context menu options "Rotate left" or "Rotate right" the new image rotation is not picked up by SFML if it's a JPEG. The image is simply loaded in its original orientation.
This problem is not present with PNG or BMP files.

Out of curiosity I compared the original and rotated versions of both PNG and JPEG files in a hex editor and found that the bytes indicating the image resolution are indeed flipped for PNG but not for JPEG.

This leads me to believe that the problem lies more within Windows than SFML, but still raises the question why other programs, like paint.net and Photoscape, are able to detect the rotation.
« Last Edit: February 25, 2016, 07:46:04 pm by guyyst »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::image can't detect Windows image rotation for JPEG files
« Reply #1 on: February 25, 2016, 08:28:49 pm »
I guess that for JPEG, Windows uses the EXIF orientation (a metadata field) instead of actually rotating the whole array of pixels. All image viewers decode and apply the EXIF orientation, SFML doesn't.
Laurent Gomila - SFML developer

guyyst

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: sf::image can't detect Windows image rotation for JPEG files
« Reply #2 on: February 25, 2016, 09:13:29 pm »
Yeah I didn't think to check if there's an EXIF tag for orientation. Libexif works just fine for reading that so I guess I can just apply the rotation myself. Thanks for the answer  :)

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: sf::image can't detect Windows image rotation for JPEG files
« Reply #3 on: February 25, 2016, 09:25:03 pm »
Or you could just actually rotate the image once and for all in some image manipulation program like Gimp or Photoshop (or something else) and then just use that rotated image...

guyyst

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: sf::image can't detect Windows image rotation for JPEG files
« Reply #4 on: February 26, 2016, 04:19:47 pm »
Or you could just actually rotate the image once and for all in some image manipulation program like Gimp or Photoshop (or something else) and then just use that rotated image...

Well this program is to be used as an image Viewer, so the whole point is to be able to handle and read any form of manipulation made to the image.