mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add pdfBackground constructor property (#4207)
This commit is contained in:
@@ -109,6 +109,10 @@ namespace sharp {
|
||||
if (HasAttr(input, "subifd")) {
|
||||
descriptor->subifd = AttrAsInt32(input, "subifd");
|
||||
}
|
||||
// // PDF background color
|
||||
if (HasAttr(input, "pdfBackground")) {
|
||||
descriptor->pdfBackground = AttrAsVectorOfDouble(input, "pdfBackground");
|
||||
}
|
||||
// Create new image
|
||||
if (HasAttr(input, "createChannels")) {
|
||||
descriptor->createChannels = AttrAsUint32(input, "createChannels");
|
||||
@@ -402,6 +406,9 @@ namespace sharp {
|
||||
if (imageType == ImageType::TIFF) {
|
||||
option->set("subifd", descriptor->subifd);
|
||||
}
|
||||
if (imageType == ImageType::PDF) {
|
||||
option->set("background", descriptor->pdfBackground);
|
||||
}
|
||||
image = VImage::new_from_buffer(descriptor->buffer, descriptor->bufferLength, nullptr, option);
|
||||
if (imageType == ImageType::SVG || imageType == ImageType::PDF || imageType == ImageType::MAGICK) {
|
||||
image = SetDensity(image, descriptor->density);
|
||||
@@ -506,6 +513,9 @@ namespace sharp {
|
||||
if (imageType == ImageType::TIFF) {
|
||||
option->set("subifd", descriptor->subifd);
|
||||
}
|
||||
if (imageType == ImageType::PDF) {
|
||||
option->set("background", descriptor->pdfBackground);
|
||||
}
|
||||
image = VImage::new_from_file(descriptor->file.data(), option);
|
||||
if (imageType == ImageType::SVG || imageType == ImageType::PDF || imageType == ImageType::MAGICK) {
|
||||
image = SetDensity(image, descriptor->density);
|
||||
|
||||
@@ -74,6 +74,7 @@ namespace sharp {
|
||||
int textSpacing;
|
||||
VipsTextWrap textWrap;
|
||||
int textAutofitDpi;
|
||||
std::vector<double> pdfBackground;
|
||||
|
||||
InputDescriptor():
|
||||
buffer(nullptr),
|
||||
@@ -108,7 +109,8 @@ namespace sharp {
|
||||
textRgba(false),
|
||||
textSpacing(0),
|
||||
textWrap(VIPS_TEXT_WRAP_WORD),
|
||||
textAutofitDpi(0) {}
|
||||
textAutofitDpi(0),
|
||||
pdfBackground{ 255.0, 255.0, 255.0, 255.0 } {}
|
||||
};
|
||||
|
||||
// Convenience methods to access the attributes of a Napi::Object
|
||||
|
||||
Reference in New Issue
Block a user