mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add support for pages option for multi-page input #1566
This commit is contained in:
@@ -71,7 +71,10 @@ namespace sharp {
|
||||
descriptor->rawWidth = AttrTo<uint32_t>(input, "rawWidth");
|
||||
descriptor->rawHeight = AttrTo<uint32_t>(input, "rawHeight");
|
||||
}
|
||||
// Page input for multi-page TIFF, PDF
|
||||
// Multi-page input (GIF, TIFF, PDF)
|
||||
if (HasAttr(input, "pages")) {
|
||||
descriptor->pages = AttrTo<int32_t>(input, "pages");
|
||||
}
|
||||
if (HasAttr(input, "page")) {
|
||||
descriptor->page = AttrTo<uint32_t>(input, "page");
|
||||
}
|
||||
@@ -254,7 +257,8 @@ namespace sharp {
|
||||
option->set("density", std::to_string(descriptor->density).data());
|
||||
}
|
||||
if (ImageTypeSupportsPage(imageType)) {
|
||||
option->set("page", descriptor->page);
|
||||
option->set("n", descriptor->pages);
|
||||
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) {
|
||||
@@ -299,7 +303,8 @@ namespace sharp {
|
||||
option->set("density", std::to_string(descriptor->density).data());
|
||||
}
|
||||
if (ImageTypeSupportsPage(imageType)) {
|
||||
option->set("page", descriptor->page);
|
||||
option->set("n", descriptor->pages);
|
||||
option->set("page", descriptor->page);
|
||||
}
|
||||
image = VImage::new_from_file(descriptor->file.data(), option);
|
||||
if (imageType == ImageType::SVG || imageType == ImageType::PDF || imageType == ImageType::MAGICK) {
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace sharp {
|
||||
int rawChannels;
|
||||
int rawWidth;
|
||||
int rawHeight;
|
||||
int pages;
|
||||
int page;
|
||||
int createChannels;
|
||||
int createWidth;
|
||||
@@ -67,6 +68,7 @@ namespace sharp {
|
||||
rawChannels(0),
|
||||
rawWidth(0),
|
||||
rawHeight(0),
|
||||
pages(1),
|
||||
page(0),
|
||||
createChannels(0),
|
||||
createWidth(0),
|
||||
|
||||
Reference in New Issue
Block a user