Magick.NET icon indicating copy to clipboard operation
Magick.NET copied to clipboard

AutoOrient does not work for Heic images

Open Charltsing opened this issue 1 year ago • 7 comments

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 avatar Jun 27 '24 14:06 Charltsing

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

dlemstra avatar Jun 27 '24 19:06 dlemstra

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

Charltsing avatar Jun 28 '24 02:06 Charltsing

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?

dlemstra avatar Jun 28 '24 10:06 dlemstra

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?

Charltsing avatar Jun 29 '24 15:06 Charltsing

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

dlemstra avatar Jun 29 '24 16:06 dlemstra

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 avatar Jun 30 '24 00:06 Charltsing

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 )

Charltsing avatar Jun 30 '24 02:06 Charltsing

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 avatar Jul 02 '24 15:07 dlemstra

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 ?

Charltsing avatar Jul 02 '24 23:07 Charltsing

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 avatar Jul 05 '24 14:07 dlemstra