mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Expose JPEG 2000 oneshot decoder option #4262
Requires libvips compiled with support for JP2 images Co-authored-by: Kleis Auke Wolthuizen <github@kleisauke.nl>
This commit is contained in:
committed by
Lovell Fuller
parent
01f6cbbaee
commit
751f9992c4
@@ -113,6 +113,10 @@ namespace sharp {
|
||||
if (HasAttr(input, "pdfBackground")) {
|
||||
descriptor->pdfBackground = AttrAsVectorOfDouble(input, "pdfBackground");
|
||||
}
|
||||
// Use JPEG 2000 oneshot mode?
|
||||
if (HasAttr(input, "jp2Oneshot")) {
|
||||
descriptor->jp2Oneshot = AttrAsBool(input, "jp2Oneshot");
|
||||
}
|
||||
// Create new image
|
||||
if (HasAttr(input, "createChannels")) {
|
||||
descriptor->createChannels = AttrAsUint32(input, "createChannels");
|
||||
@@ -434,6 +438,9 @@ namespace sharp {
|
||||
if (imageType == ImageType::PDF) {
|
||||
option->set("background", descriptor->pdfBackground);
|
||||
}
|
||||
if (imageType == ImageType::JP2) {
|
||||
option->set("oneshot", descriptor->jp2Oneshot);
|
||||
}
|
||||
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);
|
||||
@@ -541,6 +548,9 @@ namespace sharp {
|
||||
if (imageType == ImageType::PDF) {
|
||||
option->set("background", descriptor->pdfBackground);
|
||||
}
|
||||
if (imageType == ImageType::JP2) {
|
||||
option->set("oneshot", descriptor->jp2Oneshot);
|
||||
}
|
||||
image = VImage::new_from_file(descriptor->file.data(), option);
|
||||
if (imageType == ImageType::SVG || imageType == ImageType::PDF || imageType == ImageType::MAGICK) {
|
||||
image = SetDensity(image, descriptor->density);
|
||||
|
||||
@@ -78,6 +78,7 @@ namespace sharp {
|
||||
VipsAlign joinHalign;
|
||||
VipsAlign joinValign;
|
||||
std::vector<double> pdfBackground;
|
||||
bool jp2Oneshot;
|
||||
|
||||
InputDescriptor():
|
||||
autoOrient(false),
|
||||
@@ -120,7 +121,8 @@ namespace sharp {
|
||||
joinBackground{ 0.0, 0.0, 0.0, 255.0 },
|
||||
joinHalign(VIPS_ALIGN_LOW),
|
||||
joinValign(VIPS_ALIGN_LOW),
|
||||
pdfBackground{ 255.0, 255.0, 255.0, 255.0 } {}
|
||||
pdfBackground{ 255.0, 255.0, 255.0, 255.0 },
|
||||
jp2Oneshot(false) {}
|
||||
};
|
||||
|
||||
// Convenience methods to access the attributes of a Napi::Object
|
||||
|
||||
Reference in New Issue
Block a user