mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add support for page selection with multi-page TIFF input (#1204)
This commit is contained in:
committed by
Lovell Fuller
parent
8ef1532691
commit
b154cd0418
@@ -63,6 +63,10 @@ namespace sharp {
|
||||
descriptor->rawWidth = AttrTo<uint32_t>(input, "rawWidth");
|
||||
descriptor->rawHeight = AttrTo<uint32_t>(input, "rawHeight");
|
||||
}
|
||||
// Page input for multi-page TIFF
|
||||
if (HasAttr(input, "page")) {
|
||||
descriptor->page = AttrTo<uint32_t>(input, "page");
|
||||
}
|
||||
// Create new image
|
||||
if (HasAttr(input, "createChannels")) {
|
||||
descriptor->createChannels = AttrTo<uint32_t>(input, "createChannels");
|
||||
@@ -229,6 +233,9 @@ namespace sharp {
|
||||
if (imageType == ImageType::MAGICK) {
|
||||
option->set("density", std::to_string(descriptor->density).data());
|
||||
}
|
||||
if (imageType == ImageType::TIFF) {
|
||||
option->set("page", descriptor->page);
|
||||
}
|
||||
image = VImage::new_from_buffer(descriptor->buffer, descriptor->bufferLength, nullptr, option);
|
||||
if (imageType == ImageType::SVG || imageType == ImageType::PDF || imageType == ImageType::MAGICK) {
|
||||
SetDensity(image, descriptor->density);
|
||||
@@ -268,6 +275,9 @@ namespace sharp {
|
||||
if (imageType == ImageType::MAGICK) {
|
||||
option->set("density", std::to_string(descriptor->density).data());
|
||||
}
|
||||
if (imageType == ImageType::TIFF) {
|
||||
option->set("page", descriptor->page);
|
||||
}
|
||||
image = VImage::new_from_file(descriptor->file.data(), option);
|
||||
if (imageType == ImageType::SVG || imageType == ImageType::PDF || imageType == ImageType::MAGICK) {
|
||||
SetDensity(image, descriptor->density);
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace sharp {
|
||||
int rawChannels;
|
||||
int rawWidth;
|
||||
int rawHeight;
|
||||
int page;
|
||||
int createChannels;
|
||||
int createWidth;
|
||||
int createHeight;
|
||||
@@ -66,6 +67,7 @@ namespace sharp {
|
||||
rawChannels(0),
|
||||
rawWidth(0),
|
||||
rawHeight(0),
|
||||
page(0),
|
||||
createChannels(0),
|
||||
createWidth(0),
|
||||
createHeight(0) {
|
||||
|
||||
Reference in New Issue
Block a user