mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 18:40:16 +02:00
Allow page input option to be set for PDF (#1595)
This commit is contained in:
parent
2262959673
commit
5afe02be60
@ -12,7 +12,7 @@
|
||||
- `options.failOnError` **[Boolean][4]** by default halt processing and raise an error when loading invalid images.
|
||||
Set this flag to `false` if you'd rather apply a "best effort" to decode images, even if the data is corrupt or invalid. (optional, default `true`)
|
||||
- `options.density` **[Number][5]** number representing the DPI for vector images. (optional, default `72`)
|
||||
- `options.page` **[Number][5]** page number to extract for multi-page input (GIF, TIFF) (optional, default `0`)
|
||||
- `options.page` **[Number][5]** page number to extract for multi-page input (GIF, TIFF, PDF) (optional, default `0`)
|
||||
- `options.raw` **[Object][3]?** describes raw pixel input image data. See `raw()` for pixel ordering.
|
||||
- `options.raw.width` **[Number][5]?**
|
||||
- `options.raw.height` **[Number][5]?**
|
||||
|
@ -64,7 +64,7 @@ const debuglog = util.debuglog('sharp');
|
||||
* @param {Boolean} [options.failOnError=true] - by default halt processing and raise an error when loading invalid images.
|
||||
* Set this flag to `false` if you'd rather apply a "best effort" to decode images, even if the data is corrupt or invalid.
|
||||
* @param {Number} [options.density=72] - number representing the DPI for vector images.
|
||||
* @param {Number} [options.page=0] - page number to extract for multi-page input (GIF, TIFF)
|
||||
* @param {Number} [options.page=0] - page number to extract for multi-page input (GIF, TIFF, PDF)
|
||||
* @param {Object} [options.raw] - describes raw pixel input image data. See `raw()` for pixel ordering.
|
||||
* @param {Number} [options.raw.width]
|
||||
* @param {Number} [options.raw.height]
|
||||
|
@ -71,7 +71,7 @@ namespace sharp {
|
||||
descriptor->rawWidth = AttrTo<uint32_t>(input, "rawWidth");
|
||||
descriptor->rawHeight = AttrTo<uint32_t>(input, "rawHeight");
|
||||
}
|
||||
// Page input for multi-page TIFF
|
||||
// Page input for multi-page TIFF, PDF
|
||||
if (HasAttr(input, "page")) {
|
||||
descriptor->page = AttrTo<uint32_t>(input, "page");
|
||||
}
|
||||
@ -243,7 +243,7 @@ namespace sharp {
|
||||
if (imageType == ImageType::MAGICK) {
|
||||
option->set("density", std::to_string(descriptor->density).data());
|
||||
}
|
||||
if (imageType == ImageType::TIFF) {
|
||||
if (imageType == ImageType::TIFF || imageType == ImageType::PDF) {
|
||||
option->set("page", descriptor->page);
|
||||
}
|
||||
image = VImage::new_from_buffer(descriptor->buffer, descriptor->bufferLength, nullptr, option);
|
||||
@ -288,7 +288,7 @@ namespace sharp {
|
||||
if (imageType == ImageType::MAGICK) {
|
||||
option->set("density", std::to_string(descriptor->density).data());
|
||||
}
|
||||
if (imageType == ImageType::TIFF) {
|
||||
if (imageType == ImageType::TIFF || imageType == ImageType::PDF) {
|
||||
option->set("page", descriptor->page);
|
||||
}
|
||||
image = VImage::new_from_file(descriptor->file.data(), option);
|
||||
|
Loading…
x
Reference in New Issue
Block a user