ImageProcessor: Crop an Image From Center Without Resizing
I have an original image that is, say, 600x600. I want to crop just the center of the image with a size of 400x400. So, there will be 100 pixels of image on each of the four sides that will be discarded during the crop operation. The source image is hosted remotely, so it's not easy to reliably figure out what the dimensions are.
I can't seem to figure out how to do that with ImageProcessor. I've looked at these pages:
The "Crop" method sounds like what I want, except it requires me to know the dimensions of the image if I want to crop from the center. I could crop from the top left of the image, but that's not ideal.
The "Resize" method seems like it might work if I use the "Resize Crop" mode, except that stretches the image to fit the specified dimensions rather than simply cropping it.
Has anybody figured out a simple way to use ImageProcessor to crop the center of an image using specific dimensions and without resizing the image?
I just found a way to get the width/height of the original image (using a third-party API), so I don't really need an answer to this anymore (I can just use crop).
However, if anybody has an answer, I'd still be curious, and I'm sure it would help others, so please do share.
ImageProcessor: Crop an Image From Center Without Resizing
I have an original image that is, say, 600x600. I want to crop just the center of the image with a size of 400x400. So, there will be 100 pixels of image on each of the four sides that will be discarded during the crop operation. The source image is hosted remotely, so it's not easy to reliably figure out what the dimensions are.
I can't seem to figure out how to do that with ImageProcessor. I've looked at these pages:
The "Crop" method sounds like what I want, except it requires me to know the dimensions of the image if I want to crop from the center. I could crop from the top left of the image, but that's not ideal.
The "Resize" method seems like it might work if I use the "Resize Crop" mode, except that stretches the image to fit the specified dimensions rather than simply cropping it.
Has anybody figured out a simple way to use ImageProcessor to crop the center of an image using specific dimensions and without resizing the image?
I just found a way to get the width/height of the original image (using a third-party API), so I don't really need an answer to this anymore (I can just use crop).
However, if anybody has an answer, I'd still be curious, and I'm sure it would help others, so please do share.
Hi Nicholas,
It is quite easy really, all you need to do is call GetCropUrl with params...
For more details, see this page https://our.umbraco.com/documentation/getting-started/backoffice/property-editors/built-in-property-editors/image-cropper
Hope that helps
Louis
I suspect that would actually resize the image, but I haven't tested it so I'm not sure.
Also, I mentioned that this image is hosted externally, and the example you showed seems to be on a locally hosted image.
is working on a reply...