Is it possible to crop and resize at the same time with Imagesharp.Web? #168
-
I've tried |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
ResizeMode.Crop crops the excess off a given set of bounds ( Relevant API docs. If you're curious as to how we do the calculation the source code is here. P.S. In future can please use the appropriate repository (ImageSharp.Web) and topic (Q&A) for questions. I've transferred this discussion but it adds overhead that can be overwhelming when it happens often.. |
Beta Was this translation helpful? Give feedback.
-
@xumix Using
If you want to crop a specific rectangle from an image and resize that, you'll indeed need to implement that processor yourself and make sure that's added before the default |
Beta Was this translation helpful? Give feedback.
ResizeMode.Crop crops the excess off a given set of bounds (
width
&height
). Since you've only provided the width the image will be resized according to it's input aspect ratio which leaves nothing to crop. Therxy
field then denotes the center point to base any cropping on.Relevant API docs.
https://docs.sixlabors.com/api/ImageSharp/SixLabors.ImageSharp.Processing.ResizeMode.html?q=resizemode
https://docs.sixlabors.com/api/ImageSharp.Web/SixLabors.ImageSharp.Web.Processors.ResizeWebProcessor.html#SixLabors_ImageSharp_Web_Processors_ResizeWebProcessor_Xy
If you're curious as to how we do the calculation the source code is here.
https://github.com/SixLabors/ImageSharp/blob/af519602a56ae23…