### ImageMagick version

7.1.1-29

### Operating system

Linux

### Operating system, version and so on

openSUSE Leap v15.5

### Description

I have in input a picture which is reported by exiftool as:

Image Size: 4208x3120
Orientation: Mirror horizontal and rotate 270 CW

This means that it was taken with a front camera (so the mirror) and, due to the spatial orientation of the smartphone, it was shooted as landscape but in reality it is a portrait.
Using any random viewer, it is correctly handled and it is shown as a portrait image 3120x4208.
The goal is to resize the picture to a portrait of <768px> x <whatever_to_keep_aspect_ratio> but it cannot be done by using `-auto-orient` together with `-resize`.
See below.





### Steps to Reproduce

This is the command line that I use and that, in general with different orientations, works fine:

**convert -limit disk 100GiB -limit map 24GiB -limit memory 38GiB -limit area 38GB -limit time 14699 -limit thread 4 -density 72 -antialias -background 'white' -flatten -auto-orient 'mirrored_and_rotated_270_CW-original.jpg' -alpha 'remove' -resize '768x' -quality '85' -antialias -verbose -version 'mirrored_and_rotated_270_CW-resized.jpg' 2>&1**

As you can see, I'm using the `-auto-orient` option together with the `-resize 768x` so that I expect that the image is first mirrored and rotated to become portrait from landscape and, after that, I expect that the TOP side is 768px wide.

Unfortunately, it is the height that becomes 768 as if the original image was not rotated before the resizing, and to add to this I get a landscape image of 1036x768 with a right white vertical stripe and the bottom part cropped out. I tried by moving around the `-resize` and `-auto-orient` in various position before and after the input file in the command line, but always with different wrong results.

I can reach the goal by analyzing the orientation beforehand, removing the `-auto-orient` and setting the `-resize` to `x768` instead of `768x`, but this work should be done automatically by the `-auto-orient` option, not by me. Also the handling should be different depending on the orientation metadata inside the image file.

Am I doing anything wrong in the command line or is it a real bug?



### Images

This is the original image:
![mirrored_and_rotated_270_CW-original](https://github.com/ImageMagick/ImageMagick/assets/100934867/199b7f2d-3d20-4c49-9148-8aebae613edf)

This the resized one:
![mirrored_and_rotated_270_CW-resized_768x](https://github.com/ImageMagick/ImageMagick/assets/100934867/3e7b579e-a407-4a19-95d8-dbe66d36938e)
Incorrect auto-orientation when resize is applied
This is a GitHub Issue
repo:ImageMagick
owner:ImageMagick
Title : Incorrect auto-orientation when resize is applied
Issue date:

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

7.1.1-29

### Operating system

Linux

### Operating system, version and so on

openSUSE Leap v15.5

### Description

I have in input a picture which is reported by exiftool as:

Image Size: 4208x3120
Orientation: Mirror horizontal and rotate 270 CW

This means that it was taken with a front camera (so the mirror) and, due to the spatial orientation of the smartphone, it was shooted as landscape but in reality it is a portrait.
Using any random viewer, it is correctly handled and it is shown as a portrait image 3120x4208.
The goal is to resize the picture to a portrait of <768px> x <whatever_to_keep_aspect_ratio> but it cannot be done by using `-auto-orient` together with `-resize`.
See below.





### Steps to Reproduce

This is the command line that I use and that, in general with different orientations, works fine:

**convert -limit disk 100GiB -limit map 24GiB -limit memory 38GiB -limit area 38GB -limit time 14699 -limit thread 4 -density 72 -antialias -background 'white' -flatten -auto-orient 'mirrored_and_rotated_270_CW-original.jpg' -alpha 'remove' -resize '768x' -quality '85' -antialias -verbose -version 'mirrored_and_rotated_270_CW-resized.jpg' 2>&1**

As you can see, I'm using the `-auto-orient` option together with the `-resize 768x` so that I expect that the image is first mirrored and rotated to become portrait from landscape and, after that, I expect that the TOP side is 768px wide.

Unfortunately, it is the height that becomes 768 as if the original image was not rotated before the resizing, and to add to this I get a landscape image of 1036x768 with a right white vertical stripe and the bottom part cropped out. I tried by moving around the `-resize` and `-auto-orient` in various position before and after the input file in the command line, but always with different wrong results.

I can reach the goal by analyzing the orientation beforehand, removing the `-auto-orient` and setting the `-resize` to `x768` instead of `768x`, but this work should be done automatically by the `-auto-orient` option, not by me. Also the handling should be different depending on the orientation metadata inside the image file.

Am I doing anything wrong in the command line or is it a real bug?



### Images

This is the original image:
![mirrored_and_rotated_270_CW-original](https://github.com/ImageMagick/ImageMagick/assets/100934867/199b7f2d-3d20-4c49-9148-8aebae613edf)

This the resized one:
![mirrored_and_rotated_270_CW-resized_768x](https://github.com/ImageMagick/ImageMagick/assets/100934867/3e7b579e-a407-4a19-95d8-dbe66d36938e)
--- end body ---
