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

[BUG] CR2 image orientation being detected incorrectly. #2850

Open
1 task done
Webreaper opened this issue Apr 30, 2024 · 0 comments
Open
1 task done

[BUG] CR2 image orientation being detected incorrectly. #2850

Webreaper opened this issue Apr 30, 2024 · 0 comments
Labels

Comments

@Webreaper
Copy link

Webreaper commented Apr 30, 2024

Description

I'm loading and orienting a CR2 image using the code below. However, whilst ExifTool correctly shows the orientation as: Orientation = Left side, bottom (Rotate 270 CW), SkiaSharp seems to be incorrectly decoding the orientation to SKEncodedOrigin.TopLeft. This means I don't rotate the image, and the thumbnails are rendered incorrectly.

I have a sample image, but it's too large to attach, so I've zipped it and put it in my GDrive folder here:

LV1_3765.CR2.zip

Code

        var codec = SKCodec.Create(source.FullName);
        var info = codec.Info;

        // get the scale that is nearest to what we want (eg: jpg returned 512)
        var supportedScale = codec.GetScaledDimensions((float)desiredWidth / info.Width);

        // decode the bitmap at the nearest size
        var nearest = new SKImageInfo(supportedScale.Width, supportedScale.Height);
        var bmp = SKBitmap.Decode(codec, nearest);

My code then uses codec.EncodedOrigin to auto-orient the image to the right way, before I resize to generate thumbs.

Expected Behavior

I expect the image orientation to be SKEncodedOrigin.LeftBottom which would allow the image to be rotated correctly.

Actual Behavior

The image orientation is evaluated as SKEncodedOrigin.TopLeft, so my code never attempts to rotate.

Version of SkiaSharp

2.88.8 (Current)

Last Known Good Version of SkiaSharp

n/a

IDE / Editor

Rider

Platform / Operating System

.Net 8.0 on Linux, macOS

Platform / Operating System Version

Linux and MacOS

Devices

No response

Relevant Screenshots

Screenshot 2024-04-30 at 10 14 30

Relevant Log Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
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

1 participant