Changelog entry for #1595 (plus add GIF)

This commit is contained in:
Lovell Fuller 2019-03-10 17:26:26 +00:00
parent 7cafd4386c
commit 1e4597c284
4 changed files with 22 additions and 3 deletions

View File

@ -12,6 +12,10 @@ Requires libvips v8.7.4.
* Add `composite` operation supporting multiple images and blend modes; deprecate `overlayWith`.
[#728](https://github.com/lovell/sharp/issues/728)
* Add support for `page` input option to GIF and PDF.
[#1595](https://github.com/lovell/sharp/pull/1595)
[@ramiel](https://github.com/ramiel)
### v0.21 - "*teeth*"
Requires libvips v8.7.0.

View File

@ -57,7 +57,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
throw new Error('Expected width, height and channels for raw pixel input');
}
}
// Page input for multi-page TIFF
// Page input for multi-page images (GIF, TIFF, PDF)
if (is.defined(inputOptions.page)) {
if (is.integer(inputOptions.page) && is.inRange(inputOptions.page, 0, 100000)) {
inputDescriptor.page = inputOptions.page;

View File

@ -212,6 +212,16 @@ namespace sharp {
return imageType;
}
/*
Does this image type support multiple pages?
*/
bool ImageTypeSupportsPage(ImageType imageType) {
return
imageType == ImageType::GIF ||
imageType == ImageType::TIFF ||
imageType == ImageType::PDF;
}
/*
Open an image from the given InputDescriptor (filesystem, compressed buffer, raw pixel data)
*/
@ -243,7 +253,7 @@ namespace sharp {
if (imageType == ImageType::MAGICK) {
option->set("density", std::to_string(descriptor->density).data());
}
if (imageType == ImageType::TIFF || imageType == ImageType::PDF) {
if (ImageTypeSupportsPage(imageType)) {
option->set("page", descriptor->page);
}
image = VImage::new_from_buffer(descriptor->buffer, descriptor->bufferLength, nullptr, option);
@ -288,7 +298,7 @@ namespace sharp {
if (imageType == ImageType::MAGICK) {
option->set("density", std::to_string(descriptor->density).data());
}
if (imageType == ImageType::TIFF || imageType == ImageType::PDF) {
if (ImageTypeSupportsPage(imageType)) {
option->set("page", descriptor->page);
}
image = VImage::new_from_file(descriptor->file.data(), option);

View File

@ -140,6 +140,11 @@ namespace sharp {
*/
ImageType DetermineImageType(char const *file);
/*
Does this image type support multiple pages?
*/
bool ImageTypeSupportsPage(ImageType imageType);
/*
Open an image from the given InputDescriptor (filesystem, compressed buffer, raw pixel data)
*/