Skip to content

Is it possible to crop and resize at the same time with Imagesharp.Web? #168

Answered by JimBobSquarePants
xumix asked this question in Q&A
Discussion options

You must be logged in to vote

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. The rxy 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…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@xumix
Comment options

@JimBobSquarePants
Comment options

@JimBobSquarePants
Comment options

@xumix
Comment options

@JimBobSquarePants
Comment options

Answer selected by JimBobSquarePants
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants