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

Determine if picture is in portrait mode #4

Open
Mysterium-Mystery opened this issue May 24, 2024 · 2 comments
Open

Determine if picture is in portrait mode #4

Mysterium-Mystery opened this issue May 24, 2024 · 2 comments

Comments

@Mysterium-Mystery
Copy link

When you load the raw image data with MakeDcrawMemoryImage() the image is rotated correctly when it is in portrait mode. When you retrieve the thumbnail of the image using ExportThumbnail() the image is not rotated.

So I searched for a way to identify whether or not the picture is in portrait mode and there is a variable which does tell you whether or not it is. That variable is RawContext.RawData.RawData.Sizes.Flip. Sadly though RawData seems to be inaccessible.

Is there any way to determine whether the image is in portrait mode or not or could you maybe change ExportThumbnail() to rotate the image automatically or expose the Flip variable?

Any help is greatly appreciated

@sdcb
Copy link
Owner

sdcb commented Aug 19, 2024

Could you please provide an example raw file in portrait mode, as well as another example raw file in normal mode?

@ryanlah
Copy link

ryanlah commented Dec 20, 2024

@Mysterium-Mystery My solution is introducing ImageSharp take over rest of things.
Here is my sample code:

using var context = RawContext.OpenFile("rawFileToOpen");
using var memoryImage = context.MakeDcrawMemoryImage();
using var sharpImage = Image.LoadPixelData(memoryImage.AsSpan(), memoryImage.Width, memoryImage.Height);

sharpImage.Mutate(ctx =>
{
ctx.AutoOrient();
ctx.Resize(new ResizeOptions
{
Mode = ResizeMode.Max,
Size = new Size(2000, 2000),
});
});

sharpImage.Save("pathToSave");

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

No branches or pull requests

3 participants