Image Crop doesn't respect the dimensions passed
Magick.NET version
v11.3.0
Environment (Operating system, version and so on)
Windows 10 OS
Description
The image Crop method is using the wrong dimensions for cropping i.e., width is used instead of height and vice versa. I'm trying to crop an image of 1000x1000 size to the dimensions of 850x700. However, the cropped image has incorrect dimensions i.e., 700x850. We noticed this issue first on v7.22.0 of the library, and tried updating it to the latest version but the same behavior was observed.
I'm not sure if I'm missing something, can you help me understand what I'm doing wrong?
Steps to Reproduce
I've tried this on the Magick.NET.Samples project which is available within the repo using the below code:
public static void CropImage()
{
// Read from file
using (var collection = new MagickImageCollection(SampleFiles.ResizeTest))
{
// This will remove the optimization and change the image to how it looks at that point
// during the animation. More info here: http://www.imagemagick.org/Usage/anim_basics/#coalesce
collection.Coalesce();
// Resize each image in the collection to a width of 200. When zero is specified for the height
// the height will be calculated with the aspect ratio.
foreach (var image in collection)
{
image.Crop(850, 700, Gravity.Center);
}
// Save the result
collection.Write(SampleFiles.OutputDirectory + "Resize_Test-resized.jpg");
}
}
Input image 
Output Image: 
P.S: What I've noticed is that after executing the 'Crop' function, the 'image' object has the width and height properties set correctly. However, when the new image is written to the output folder using 'collection.Write' the output image has the incorrect dimentions i.e,. 700x850
Your image is actually 850x700 but most programs that show the image automatically change the image orientation. This are the real dimensions of tour image:
identify output.jpg
output.jpg JPEG 850x700 850x700+0+0 8-bit sRGB 436047B 0.000u 0:00.001
Hey Dirk,
Thanks for the prompt response. I didn't quite understand the orientation bit though, I've tried checking the dimensions of the image using different tools, including some online sites and all of them show the dimensions as 700x850.
Regardless, the crop I'm expecting is not what I'm getting. I'm using the option Gravity.Center, i.e,. image.Crop(850,700, Gravity.Center) so I'm expecting the image to be cropped as shown below.
Expected Crop: For Gravity Centre => x: 75, y: 150

However, the cropped image I'm getting is this
Actual Crop: For Gravity Center => x: 150, y: 75

I'm assuming that I'm calling the crop method correctly? Is there anything else I need to consider?
When you are viewing the image you are seeing it being auto rotated to the TopLeft orientation. Your image normally would look like this:

So when you cut out an area your are cutting out the image that is not yet rotated to how you are viewing it there. When you call image.AutoOrient() the image will be rotated and it will be shown as you are viewing it.
Hi Dirk,
I wasn't aware of the auto orientation of the input image. Understood it now.
And yes, using image.AutoOrient() I was able to get the right result.
Thanks a lot for explaining this!