SVGs Only: dpr and rect produce incorrectly cropped image
This may be a duplicate of #32 but I have found this when trying to transform SVGs, which I understand are untouched unless exported as a different format. I'm outputting the SVG as "webp" via .format('webp').
✅ Original Image
You can test this with any SVG using the query parameters in the URL but here is an SVG that is 608 wide and 320 wide:
To ensure that cropping is actually working, let's update the rect parameter to actually crop the image. Below, I've moved the starting point of the crop to 200 pixels in from the left and the top (rect=200,200,408,120). This isn't necessary, but to keep the same size ratio, I've also subtracted 200 pixels from the width property (w=408).
If I apply any dpr alongside rect the image is jacked up. Below, I've added &dpr=2&rect=0,0,608,320 that should increase the resolution of the image but essentially do no cropping. Alas, it incorrectly crops the image. Ratfarts!
For sanity's sake (pun intended), let's update the rect and width parameters to actually crop the image like we did before (rect=200,200,408,120, w=408).
SVGs Only:
dpr
andrect
produce incorrectly cropped imageThis may be a duplicate of #32 but I have found this when trying to transform SVGs, which I understand are untouched unless exported as a different format. I'm outputting the SVG as
"webp"
via.format('webp')
.✅ Original Image
You can test this with any SVG using the query parameters in the URL but here is an SVG that is
608
wide and320
wide:✅ Apply
rect
If I apply
rect
, the image is cropped. Great! Below, I've added&rect=0,0,608,320
that essentially does nothing.To ensure that cropping is actually working, let's update the
rect
parameter to actually crop the image. Below, I've moved the starting point of the crop to200
pixels in from theleft
and thetop
(rect=200,200,408,120
). This isn't necessary, but to keep the same size ratio, I've also subtracted200
pixels from the width property (w=408
).✅ Remove
rect
, applydpr
If I remove the
rect
parameter and append&dpr=2
to the end, I get a scaled version of the original image. Fantastic!🚫 Apply
dpr
andrect
If I apply any
dpr
alongsiderect
the image is jacked up. Below, I've added&dpr=2&rect=0,0,608,320
that should increase the resolution of the image but essentially do no cropping. Alas, it incorrectly crops the image. Ratfarts!For sanity's sake (pun intended), let's update the
rect
andwidth
parameters to actually crop the image like we did before (rect=200,200,408,120
,w=408
).This issue does not present itself for
png
images. I only tested againstsvg
but I suspect it may be present forgif
, as well.