Exif orientation with LoadImage
Exif orientation with LoadImage
It looks like the exif orientation is not handled properly with LoadImage.
I have an image from my digital camera that is taken in portrait orientation, shows fine in OSX Preview but is in landscape orientation when PureBasic loads the image (90 degrees rotated compared to how it should look).
I have an image from my digital camera that is taken in portrait orientation, shows fine in OSX Preview but is in landscape orientation when PureBasic loads the image (90 degrees rotated compared to how it should look).
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Exif orientation with LoadImage
Hi wilbert,
I would not call this a bug.
The image is loaded as it is inside the file.
EXIF is only an addition.
It is not handled. Yes, that's true.
But I would call it a feature request and not a bug.
In IrfanView it is an option, which is disabled as default (if I'm right).
Bernd
I would not call this a bug.
The image is loaded as it is inside the file.
EXIF is only an addition.
It is not handled. Yes, that's true.
But I would call it a feature request and not a bug.
In IrfanView it is an option, which is disabled as default (if I'm right).
Bernd
Re: Exif orientation with LoadImage
I think PureBasic should respect the Operating System it is working on.
I tried OSX Preview, Acorn image editor, Photoshop Elements, Safari, Chrome, Firefox (all on OSX) and every one of them handles the image orientation correctly. The only one which behaves differently is PureBasic.
The other applications probably all use the jpeg decoder built into OSX itself while PureBasic uses its own decoder.
I tried OSX Preview, Acorn image editor, Photoshop Elements, Safari, Chrome, Firefox (all on OSX) and every one of them handles the image orientation correctly. The only one which behaves differently is PureBasic.
The other applications probably all use the jpeg decoder built into OSX itself while PureBasic uses its own decoder.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Exif orientation with LoadImage
I think Bernd is right.
EXIF is an addition, which you can read and use as you like.
Otherwise PB should read the color profile too, what is not does.
Did you try what's happened if you load it by cocoa?
EXIF is an addition, which you can read and use as you like.
Otherwise PB should read the color profile too, what is not does.
Did you try what's happened if you load it by cocoa?
macOS Catalina 10.15.7
Re: Exif orientation with LoadImage
After some more thinking, you both do have a point. Maybe it should be a feature request.Wolfram wrote:I think Bernd is right.
EXIF is an addition, which you can read and use as you like.
Otherwise PB should read the color profile too, what is not does.
Did you try what's happened if you load it by cocoa?
I just was surprised the image didn't load correctly (from my point of view).
If I load it with Cocoa, the orientation is fine. So that's a good alternative.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: Exif orientation with LoadImage
Moved to feature requests.
quidquid Latine dictum sit altum videtur
Re: Exif orientation with LoadImage
LOADIMAGE has a 3rd unused parameter, #flag.
What about using it to auto rotate images?
If 0, load as is, if #PB_Image_Idontknow the loadimage function will autorotate the image using EXIF info.
What about using it to auto rotate images?
If 0, load as is, if #PB_Image_Idontknow the loadimage function will autorotate the image using EXIF info.
Re: Exif orientation with LoadImage
+1 as a flag, not the default.
wilbert, I have procedures that will handle this, if you want a workaround for now.
wilbert, I have procedures that will handle this, if you want a workaround for now.
Re: Exif orientation with LoadImage
Cool if you have this! Sent me a link, please.
Re: Exif orientation with LoadImage
I did not realize this thread was 5 years old when I replied
AMpos, save my IncludeFiles RotateImage.pbi and GetExifData.pbi
https://raw.githubusercontent.com/kenmo ... eImage.pbi
https://raw.githubusercontent.com/kenmo ... ifData.pbi
and then try:
AMpos, save my IncludeFiles RotateImage.pbi and GetExifData.pbi
https://raw.githubusercontent.com/kenmo ... eImage.pbi
https://raw.githubusercontent.com/kenmo ... ifData.pbi
and then try:
Code: Select all
XIncludeFile "RotateImage.pbi"
XIncludeFile "GetExifData.pbi"
LoadImageEXIFRotated(0, MyFile)
Re: Exif orientation with LoadImage
The above includes don't work with this image -> https://www.dropbox.com/s/oe2sf7je8a8d1 ... d.jpg?dl=1
Note: Clicking the link will auto-download the file, because saving it from your browser will remove the EXIF data.
It fails to detect the orientation ("Right top" in EXIF data):
However, LoadImage() loads it in the correct orientation:
Note: Clicking the link will auto-download the file, because saving it from your browser will remove the EXIF data.
It fails to detect the orientation ("Right top" in EXIF data):
Code: Select all
XIncludeFile "RotateImage.pbi"
XIncludeFile "GetExifData.pbi"
Debug LoadImageEXIFRotated(0, "D:\Keyboard.jpg") ; Returns 0
Re: Exif orientation with LoadImage
Hello @BarryG
There are two things going on here:
1. You are correct! My code had a bug in reading Little Endian encoded EXIF orientation. (Most of my test JPEGs are apparently Big Endian.)
I have pushed an update to GetExifData.pbi which should work. Don't forget UseJpegImageDecoder()
https://github.com/kenmo-pb/includes/bl ... ifData.pbi
2. PB's LoadImage() does not process EXIF orientation. What you're showing as "correct" has not been EXIF-rotated.
Try opening Keyboard.jpg in Firefox or Chrome or another pro software, you should see it rotated extra 90 clockwise.
My updated code should detect Keyboard.jpg needing a 90 CW rotation, matching Firefox etc.
I think it's confusing because the un-rotated PB result looks like the expected, natural orientation.
There are two things going on here:
1. You are correct! My code had a bug in reading Little Endian encoded EXIF orientation. (Most of my test JPEGs are apparently Big Endian.)
I have pushed an update to GetExifData.pbi which should work. Don't forget UseJpegImageDecoder()
https://github.com/kenmo-pb/includes/bl ... ifData.pbi
2. PB's LoadImage() does not process EXIF orientation. What you're showing as "correct" has not been EXIF-rotated.
Try opening Keyboard.jpg in Firefox or Chrome or another pro software, you should see it rotated extra 90 clockwise.
My updated code should detect Keyboard.jpg needing a 90 CW rotation, matching Firefox etc.
I think it's confusing because the un-rotated PB result looks like the expected, natural orientation.