sharp icon indicating copy to clipboard operation
sharp copied to clipboard

withoutEnlargement=true should not take effect when input is SVG or PDF

Open adityapatadia opened this issue 2 years ago • 3 comments

We always set withoutEnlargement=true when processing images. This prevents image upscaling if width supplied is larger than needed.

This should ideally be ignored by sharp library when input is vector. SVG or PDF have no inherent width and with latest sharp update, the correct density for given width is automatically determined. This should ideally make withoutEnlargement flag ineffective. Problem happens when withoutEnlargement=true and we try to set something like width:2000. It never outputs that big image.

adityapatadia avatar May 03 '22 14:05 adityapatadia

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

Please provide sample image(s) that help explain this problem

lovell avatar May 03 '22 15:05 lovell

@adityapatadia Were you able to make any progress with providing the requested information?

lovell avatar Jun 08 '22 11:06 lovell

I can provide a code when I get time but the behaviour is exactly what I described. Take SVG as input image and try to output say 3000 pixel width while passing withoutEnlagement: true. It will never output big image while ideally it should as input is vector and enlargement does not apply to vectors.

adityapatadia avatar Jun 08 '22 20:06 adityapatadia

Closing due to inactivity but please feel free to reopen with the requested details if further help is required.

lovell avatar Aug 13 '22 23:08 lovell

FWIW, you can just omit the withoutEnlargement=true parameter when resizing vector images. I think producing a different image based on the image type would certainly make things too complicated and confusing.

See also the discussion in: https://github.com/weserv/images/issues/333.

kleisauke avatar Nov 17 '22 10:11 kleisauke