Open omegayal opened 2 years ago
We'd need to expose the background
option in the constructor API. Happy to accept a PR, if you're able.
https://sharp.pixelplumbing.com/api-constructor#parameters https://www.libvips.org/API/current/VipsForeignSave.html#vips-pdfload
This is also something I'm interested in.
I explored writing a PR. Figured it would be easy since I could follow the code path to get the level
constructor option to vips but after ~10min I got stuck on:
background
is a VipsArrayDouble
(source). Couldn't find an example of how to construct a VipsArrayDouble
in this repository. I did find the code for options.create.background
(source) which I expect is in the neighborhood of what one would want here.@calebmer Great, thanks for taking a look at this. Perhaps you could copy the approach taken for properties such as resizeBackground
that use the AttrAsVectorOfDouble
helper? As you say, we won't be able to fully test this feature, but hopefully can at least have a couple of sanity checks e.g. valid vs invalid values.
Ok, following the resizeBackground
example I was able to attempt a fix: https://github.com/lovell/sharp/pull/4207
hello @lovell is this stiil an issue ?
Question about an existing feature
When install a custom libvips with PDF support, we can convert a PDF file to an PNG image with sharp. However, when the PDF has transparent background, the output image always shows white background.
What are you trying to achieve?
https://github.com/libvips/libvips/issues/995 It seems that libvips provides the option "background" when converting PDF to PNG with transparent background:
vips copy transparent.pdf[background=0] x.png
Does sharp also have such option? Thanks.