### ImageMagick version

7.1.1-26

### Operating system

Other (enter below)

### Operating system, version and so on

FreeBSD 14

### Description

Wrong image orientation using MagickBooleanType MagickAutoOrientImage(MagickWand *wand)

### Steps to Reproduce

Here is the EXIF information. As a result of auto orientation the image is rotated incorrectly at 90 CW but should be rotated at 90 CCW!

```
ExifTool Version Number         : 12.50
File Name                       : pwhc7j1vpy7h
Directory                       : .
File Size                       : 36 MB
File Modification Date/Time     : 2024:05:10 21:16:26+03:00
File Access Date/Time           : 2024:05:10 23:05:59+03:00
File Inode Change Date/Time     : 2024:05:10 21:16:26+03:00
File Permissions                : -rw-rw-rw-
File Type                       : DNG
File Type Extension             : dng
MIME Type                       : image/x-adobe-dng
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : Apple
Camera Model Name               : iPhone 12 Pro
Preview Image Start             : 63556
Orientation                     : Rotate 90 CW
Rows Per Strip                  : 3024
Preview Image Length            : 7549126
Software                        : 17.5
Modify Date                     : 2024:04:18 13:52:39
Subfile Type                    : Full-resolution image
Image Width                     : 4032
Image Height                    : 3024
Bits Per Sample                 : 12 12 12
Compression                     : JPEG
Photometric Interpretation      : Linear Raw
Samples Per Pixel               : 3
Planar Configuration            : Chunky
Tile Width                      : 504
Tile Length                     : 504
Tile Offsets                    : (Binary data 427 bytes, use -b option to extract)
Tile Byte Counts                : (Binary data 335 bytes, use -b option to extract)
Linearization Table             : (Binary data 21699 bytes, use -b option to extract)
Black Level                     : 0 0 0
White Level                     : 65535 65535 65535
Noise Profile                   : 3e-05 3e-08
Default Black Render            : None
Profile Gain Table Map          : (Binary data 49408 bytes, use -b option to extract)
Exposure Time                   : 1/428
F Number                        : 2.0
Exposure Program                : Program AE
ISO                             : 25
Exif Version                    : 0232
Date/Time Original              : 2024:04:18 13:52:39
Create Date                     : 2024:04:18 13:52:39
Offset Time                     : +03:00
Offset Time Original            : +03:00
Offset Time Digitized           : +03:00
Shutter Speed Value             : 1/428
Aperture Value                  : 2.0
Brightness Value                : 7.707632833
Exposure Compensation           : 0
Metering Mode                   : Multi-segment
Flash                           : Off, Did not fire
Focal Length                    : 6.0 mm
Subject Area                    : 2004 1514 2318 1393
Run Time Flags                  : Valid
Run Time Value                  : 2995265885958
Run Time Scale                  : 1000000000
Run Time Epoch                  : 0
Acceleration Vector             : -0.03274015709 -0.9480307104 -0.3352252245
Focus Distance Range            : 3.33 - 3.37 m
Live Photo Video Index          : 1112547584
Sub Sec Time Original           : 136
Sub Sec Time Digitized          : 136
Exif Image Width                : 4032
Exif Image Height               : 3024
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Exposure Mode                   : Auto
White Balance                   : Auto
Focal Length In 35mm Format     : 52 mm
Lens Info                       : 1.539999962-6mm f/1.6-2.4
Lens Make                       : Apple
Lens Model                      : iPhone 12 Pro back triple camera 6mm f/2
Composite Image                 : General Composite Image
GPS Latitude Ref                : North
GPS Longitude Ref               : East
GPS Altitude Ref                : Above Sea Level
GPS Time Stamp                  : 10:52:38
GPS Speed Ref                   : km/h
GPS Speed                       : 0
GPS Img Direction Ref           : True North
GPS Img Direction               : 259.9790649
GPS Dest Bearing Ref            : True North
GPS Dest Bearing                : 259.9790649
GPS Date Stamp                  : 2024:04:18
GPS Horizontal Positioning Error: 6.59729063 m
DNG Version                     : 1.6.0.0
DNG Backward Version            : 1.3.0.0
Unique Camera Model             : iPhone13,3 back telephoto camera
Color Matrix 1                  : 1.210916758 -0.5171784163 -0.2446352243 -0.4480841756 1.493248224 0.007582519203 -0.04304760322 0.1864003539 0.6076977849
Color Matrix 2                  : 0.8891333342 -0.2923306227 -0.1202171519 -0.421434015 1.284245372 0.1107940823 -0.1072451025 0.2506295443 0.4410457015
Analog Balance                  : 2.121582031 1 1.820556641
As Shot Neutral                 : 1 1 1
Baseline Exposure               : 4.041075706
Baseline Sharpness              : 1.5
Calibration Illuminant 1        : Standard Light A
Calibration Illuminant 2        : D65
Noise Reduction Applied         : 0.9499999881
Profile Name                    : Apple Embedded Color Profile
Warning                         : [Minor] Not decoding some large array(s). Ignore minor errors to decode
Profile Tone Curve              : (large array of 514 float values)
Run Time Since Power Up         : 0:49:55
Aperture                        : 2.0
Image Size                      : 4032x3024
Megapixels                      : 12.2
Preview Image                   : (Binary data 7549126 bytes, use -b option to extract)
Scale Factor To 35 mm Equivalent: 8.7
Shutter Speed                   : 1/428
Create Date                     : 2024:04:18 13:52:39.136+03:00
Date/Time Original              : 2024:04:18 13:52:39.136+03:00
Modify Date                     : 2024:04:18 13:52:39+03:00
GPS Altitude                    : 622.9 m Above Sea Level
GPS Date/Time                   : 2024:04:18 10:52:38Z
GPS Latitude                    : 42 deg 38' 20.73" N
GPS Longitude                   : 23 deg 23' 0.78" E
Circle Of Confusion             : 0.003 mm
Field Of View                   : 38.2 deg
Focal Length                    : 6.0 mm (35 mm equivalent: 52.0 mm)
GPS Position                    : 42 deg 38' 20.73" N, 23 deg 23' 0.78" E
Hyperfocal Distance             : 5.19 m
Light Value                     : 12.7
Lens ID                         : iPhone 12 Pro back triple camera 6mm f/2
```



### Images

_No response_
Wrong image auto orientation ?
This is a GitHub Issue
repo:ImageMagick
owner:ImageMagick
Title : Wrong image auto orientation ?
Issue date:

--- start body ---
### ImageMagick version

7.1.1-26

### Operating system

Other (enter below)

### Operating system, version and so on

FreeBSD 14

### Description

Wrong image orientation using MagickBooleanType MagickAutoOrientImage(MagickWand *wand)

### Steps to Reproduce

Here is the EXIF information. As a result of auto orientation the image is rotated incorrectly at 90 CW but should be rotated at 90 CCW!

```
ExifTool Version Number         : 12.50
File Name                       : pwhc7j1vpy7h
Directory                       : .
File Size                       : 36 MB
File Modification Date/Time     : 2024:05:10 21:16:26+03:00
File Access Date/Time           : 2024:05:10 23:05:59+03:00
File Inode Change Date/Time     : 2024:05:10 21:16:26+03:00
File Permissions                : -rw-rw-rw-
File Type                       : DNG
File Type Extension             : dng
MIME Type                       : image/x-adobe-dng
Exif Byte Order                 : Big-endian (Motorola, MM)
Make                            : Apple
Camera Model Name               : iPhone 12 Pro
Preview Image Start             : 63556
Orientation                     : Rotate 90 CW
Rows Per Strip                  : 3024
Preview Image Length            : 7549126
Software                        : 17.5
Modify Date                     : 2024:04:18 13:52:39
Subfile Type                    : Full-resolution image
Image Width                     : 4032
Image Height                    : 3024
Bits Per Sample                 : 12 12 12
Compression                     : JPEG
Photometric Interpretation      : Linear Raw
Samples Per Pixel               : 3
Planar Configuration            : Chunky
Tile Width                      : 504
Tile Length                     : 504
Tile Offsets                    : (Binary data 427 bytes, use -b option to extract)
Tile Byte Counts                : (Binary data 335 bytes, use -b option to extract)
Linearization Table             : (Binary data 21699 bytes, use -b option to extract)
Black Level                     : 0 0 0
White Level                     : 65535 65535 65535
Noise Profile                   : 3e-05 3e-08
Default Black Render            : None
Profile Gain Table Map          : (Binary data 49408 bytes, use -b option to extract)
Exposure Time                   : 1/428
F Number                        : 2.0
Exposure Program                : Program AE
ISO                             : 25
Exif Version                    : 0232
Date/Time Original              : 2024:04:18 13:52:39
Create Date                     : 2024:04:18 13:52:39
Offset Time                     : +03:00
Offset Time Original            : +03:00
Offset Time Digitized           : +03:00
Shutter Speed Value             : 1/428
Aperture Value                  : 2.0
Brightness Value                : 7.707632833
Exposure Compensation           : 0
Metering Mode                   : Multi-segment
Flash                           : Off, Did not fire
Focal Length                    : 6.0 mm
Subject Area                    : 2004 1514 2318 1393
Run Time Flags                  : Valid
Run Time Value                  : 2995265885958
Run Time Scale                  : 1000000000
Run Time Epoch                  : 0
Acceleration Vector             : -0.03274015709 -0.9480307104 -0.3352252245
Focus Distance Range            : 3.33 - 3.37 m
Live Photo Video Index          : 1112547584
Sub Sec Time Original           : 136
Sub Sec Time Digitized          : 136
Exif Image Width                : 4032
Exif Image Height               : 3024
Sensing Method                  : One-chip color area
Scene Type                      : Directly photographed
Exposure Mode                   : Auto
White Balance                   : Auto
Focal Length In 35mm Format     : 52 mm
Lens Info                       : 1.539999962-6mm f/1.6-2.4
Lens Make                       : Apple
Lens Model                      : iPhone 12 Pro back triple camera 6mm f/2
Composite Image                 : General Composite Image
GPS Latitude Ref                : North
GPS Longitude Ref               : East
GPS Altitude Ref                : Above Sea Level
GPS Time Stamp                  : 10:52:38
GPS Speed Ref                   : km/h
GPS Speed                       : 0
GPS Img Direction Ref           : True North
GPS Img Direction               : 259.9790649
GPS Dest Bearing Ref            : True North
GPS Dest Bearing                : 259.9790649
GPS Date Stamp                  : 2024:04:18
GPS Horizontal Positioning Error: 6.59729063 m
DNG Version                     : 1.6.0.0
DNG Backward Version            : 1.3.0.0
Unique Camera Model             : iPhone13,3 back telephoto camera
Color Matrix 1                  : 1.210916758 -0.5171784163 -0.2446352243 -0.4480841756 1.493248224 0.007582519203 -0.04304760322 0.1864003539 0.6076977849
Color Matrix 2                  : 0.8891333342 -0.2923306227 -0.1202171519 -0.421434015 1.284245372 0.1107940823 -0.1072451025 0.2506295443 0.4410457015
Analog Balance                  : 2.121582031 1 1.820556641
As Shot Neutral                 : 1 1 1
Baseline Exposure               : 4.041075706
Baseline Sharpness              : 1.5
Calibration Illuminant 1        : Standard Light A
Calibration Illuminant 2        : D65
Noise Reduction Applied         : 0.9499999881
Profile Name                    : Apple Embedded Color Profile
Warning                         : [Minor] Not decoding some large array(s). Ignore minor errors to decode
Profile Tone Curve              : (large array of 514 float values)
Run Time Since Power Up         : 0:49:55
Aperture                        : 2.0
Image Size                      : 4032x3024
Megapixels                      : 12.2
Preview Image                   : (Binary data 7549126 bytes, use -b option to extract)
Scale Factor To 35 mm Equivalent: 8.7
Shutter Speed                   : 1/428
Create Date                     : 2024:04:18 13:52:39.136+03:00
Date/Time Original              : 2024:04:18 13:52:39.136+03:00
Modify Date                     : 2024:04:18 13:52:39+03:00
GPS Altitude                    : 622.9 m Above Sea Level
GPS Date/Time                   : 2024:04:18 10:52:38Z
GPS Latitude                    : 42 deg 38' 20.73" N
GPS Longitude                   : 23 deg 23' 0.78" E
Circle Of Confusion             : 0.003 mm
Field Of View                   : 38.2 deg
Focal Length                    : 6.0 mm (35 mm equivalent: 52.0 mm)
GPS Position                    : 42 deg 38' 20.73" N, 23 deg 23' 0.78" E
Hyperfocal Distance             : 5.19 m
Light Value                     : 12.7
Lens ID                         : iPhone 12 Pro back triple camera 6mm f/2
```



### Images

_No response_
--- end body ---

None