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

AutoOrient does not work for Heic images #1662

Closed
Charltsing opened this issue Jun 27, 2024 · 10 comments
Closed

AutoOrient does not work for Heic images #1662

Charltsing opened this issue Jun 27, 2024 · 10 comments
Milestone

Comments

@Charltsing
Copy link

Charltsing commented Jun 27, 2024

Magick.NET version

13.9.1

Environment (Operating system, version and so on)

Windows10, net framework 4.7.2

Description

AutoOrient() not work

Steps to Reproduce

HEIC_rotation.zip

1

@Charltsing Charltsing changed the title AutoOrient is not work for Heic images AutoOrient does not work for Heic images Jun 27, 2024
@dlemstra
Copy link
Owner

Thanks for sharing the images but I have no idea what your issue is?

@Charltsing
Copy link
Author

Charltsing commented Jun 28, 2024

Thanks for sharing the images but I have no idea what your issue is?

AutoOrient(),The image should automatically rotate in the direction of the arrow, with the arrow pointing upwards

i test jpg , it work fine. but heic, it not work fine

i update sample image.(By the way, I'm not sure if 90.heic should be rotated 90 or 270 degrees, I don't understand the Heic image format)

1

2

3

4

@dlemstra
Copy link
Owner

dlemstra commented Jun 28, 2024

Heic images should automatically be orientated to the right direction? You should not need to AutoOrient them. Please provide a small code sample that demonstrates your issue?

@Charltsing
Copy link
Author

I don't quite understand the definition of the orientation tag in the heic image format.

90.heic as an example, the default rotation of this image is 270 degrees
My understanding is that after using AutoOrient or not using AutoOrient, the image should be displayed in different directions. Either the arrow direction of the image after using AutoOrient is left, or the arrow direction of the image without AutoOrient is left.
But the arrow direction should not be left in both cases.

Maybe there is something wrong with my understanding of AutoOrient?

@dlemstra
Copy link
Owner

Heic images are automatically "auto oriented" when they are being read.

@Charltsing
Copy link
Author

Charltsing commented Jun 30, 2024

This issue comes from here

How can I make the image show the correct orientation?

i try copytrans, The orientation of the images is correct
23

it is ImageGlass (Magick.Net 13.9.1), The orientation of the images is incorrect
44

i try Openize.HEIC, The orientation of the images is correct
55

@Charltsing
Copy link
Author

i set PreserveOrientation = false, The orientation of the images is correct
settings.SetDefines(new HeicReadDefines
{
PreserveOrientation = false,
});

so, AutoOrient is invalid for heic ?

BaseWidth is always the same as Width ( PreserveOrientation = false or true ), I think there should be at least one case where BaseWidth should not be the same as Width, ( Openize.HEIC---- ispeWidth not same as Width )

@dlemstra
Copy link
Owner

dlemstra commented Jul 2, 2024

BaseWidth and BaseHeight will return the original Width or Height that was read. The library that we are using to read heic files will automatically read the image in TopLeft orientation and has a special flag to disable this behavior (PreserveOrientation). And then you might need to use AutoOrient . But it is recommended to just let the heic coder decide this.

@dlemstra dlemstra closed this as completed Jul 2, 2024
@Charltsing
Copy link
Author

Charltsing commented Jul 2, 2024

i test 90.heic
set PreserveOrientation = false AutoOrient() does not work , MagickImage.Orientation is always TopLeft.
if set PreserveOrientation = true, MagickImage.Orientation is Undefined, then AutoOrient(), MagickImage.Orientation is TopLeft.

So I cannot know if the direction of 90.heic is rotating 270 degrees

heic image will lost Original orientation information ?

@dlemstra
Copy link
Owner

dlemstra commented Jul 5, 2024

I finally had some time to take a deeper look at what you were asking. The Orientation should not be Undefined when you set the PreserveOrientation option but it looks like we never implemented something in ImageMagick to read that information. I just pushed a patch to the ImageMagick repository to add support for this. You will get the correct orientation in the next release when you specify PreserveOrientation.

@dlemstra dlemstra added this to the 13.9.2 milestone Jul 6, 2024
@dlemstra dlemstra reopened this Jul 6, 2024
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

2 participants