Closed bertasoft closed 5 months ago
I’m not sure what you are expecting here. The image was rotated to match the exif orientation.
I'm expected that the rotated is like this
That's an incorrect assumption. AutoOrient
update the orientation of the image to match the EXIF metadata properties and removes those properties from the metadata.
As you can see on your breakpoints. The input image has physical dimensions of 1536x2048 (portrait) but is displayed rotated 90degrees (landscape). Once processed the image pixels are 2048x1536 which matches the landscape display orientation of the input.
Ok, how can I have the rotated version of the image like my example?
Something that follow the exif infos and give me the jpg rotated, any c# code example?
Now i'm using something like this
private const int exifOrientationID = 0x112; //274
public static void ExifRotate(this Image img) { if (!img.PropertyIdList.Contains(exifOrientationID)) return;
var prop = img.GetPropertyItem(exifOrientationID);
int val = BitConverter.ToUInt16(prop.Value, 0);
var rot = RotateFlipType.RotateNoneFlipNone;
if (val == 3 || val == 4)
rot = RotateFlipType.Rotate180FlipNone;
else if (val == 5 || val == 6)
rot = RotateFlipType.Rotate90FlipNone;
else if (val == 7 || val == 8)
rot = RotateFlipType.Rotate270FlipNone;
if (val == 2 || val == 4 || val == 5 || val == 7)
rot |= RotateFlipType.RotateNoneFlipX;
if (rot != RotateFlipType.RotateNoneFlipNone)
{
img.RotateFlip(rot);
img.RemovePropertyItem(exifOrientationID);
}
}
Thanks for clarification,
Prerequisites
DEBUG
andRELEASE
modeImageSharp version
3.1.3
Other ImageSharp packages and versions
no package
Environment (Operating system, version and so on)
Windows 11
.NET Framework version
NET 8
Description
Exif rotation and save
3.1.3
I have some Exif image to adjust but the library don't give the expected result.
Before![Screenshot 2024-03-09 101858](https://github.com/SixLabors/ImageSharp/assets/926243/d817d34e-da61-4c6d-993c-a881cd8abb1b)
After, the library make the rotation![Screenshot 2024-03-09 101919](https://github.com/SixLabors/ImageSharp/assets/926243/4e607cdd-9c15-4c0a-b2b2-e1102678ba28)
But it doesn't save correctly![Screenshot 2024-03-09 101953](https://github.com/SixLabors/ImageSharp/assets/926243/c9ba6d69-dc7f-4b3c-aad2-da15a4c0f9d0)
In the attachment the image that i used
Thanks
Steps to Reproduce
Look the description
Images