Bad cropping
Hi, I'm getting wrong results with cropping
If you check this image (https://res.cloudinary.com/crikle/image/upload/b_rgb:c11e31/eef7a54a-a496-4be8-a968-309e5f8dc5ef.png) you'll notice that both naturalWidth and naturalHeight are 852px
If I then use the crop transformation to remove just 1px (so setting with and height to 851px) you'll then notice that it removes a lot more than that https://res.cloudinary.com/crikle/image/upload/c_crop,x_0,y_0,w_851,h_851,b_rgb:c11e31/eef7a54a-a496-4be8-a968-309e5f8dc5ef.png
Can you help me?
Thanks
-
Hi Guillo,
The reason for this is because you are using the crop mode of "crop" which crops the image to the requested dimensions without resizing or scaling the image. By default it will select the centre of the image e.g:
https://res.cloudinary.com/crikle/image/upload/c_crop,w_851,h_851,b_rgb:c11e31/eef7a54a-a496-4be8-a968-309e5f8dc5ef.pngBut in your case, you also supplied x_0 and y_0 so that is why it cropped to the top-left (g_north_west) region.
https://res.cloudinary.com/crikle/image/upload/c_crop,x_0,y_0,w_851,h_851,b_rgb:c11e31/eef7a54a-a496-4be8-a968-309e5f8dc5ef.pngAs you are requesting the same Aspect Ratio, just smaller dimensions, you can use the crop mode "scale" rather than "crop" and in this case, you will also not need the x, y coordinates too. E.g.
https://res.cloudinary.com/crikle/image/upload/c_scale,w_851,h_851,b_rgb:c11e31/eef7a54a-a496-4be8-a968-309e5f8dc5ef.pngYou can find out more details on those and all other available crop modes in the following section of the documentation:
https://cloudinary.com/documentation/transformation_reference#c_crop_resize0 -
Hi Aleksandar,
Thank you for your rely. I understand this, but my point is that the image is 852px by 852px and that's not respected in the cropping. It looks scaled up.
Regards,
Guillermo
0 -
Thanks, Guillermo - I see what you mean, makes sense.
I see the SVG has width/height set to 638.9pt which is about 852px. If I update the SVG to have the dimensions in px rather than pt, then upload that as the original and try the same transformation it returns the expected result below.
I noticed the SVGs are generated via Gravit.io, is there an option there to export the SVGs with sizes in px rather than pt? Or do you encounter this issue with other SVG/sources? I just want to double-check if the dimensions in pt is the only case this behaviour is encountered. I will check internally with our team also.
0 -
I, see. Good catch Aleksandar!
Thanks0
Post is closed for comments.
Comments
4 comments