mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Expose unlimited option for HEIF input
This commit is contained in:
@@ -164,7 +164,7 @@ namespace sharp {
|
||||
descriptor->limitInputPixels = static_cast<uint64_t>(AttrAsInt64(input, "limitInputPixels"));
|
||||
// Allow switch from random to sequential access
|
||||
descriptor->access = AttrAsBool(input, "sequentialRead") ? VIPS_ACCESS_SEQUENTIAL : VIPS_ACCESS_RANDOM;
|
||||
// Remove safety features and allow unlimited SVG/PNG/JPEG input
|
||||
// Remove safety features and allow unlimited input
|
||||
descriptor->unlimited = AttrAsBool(input, "unlimited");
|
||||
return descriptor;
|
||||
}
|
||||
@@ -334,6 +334,17 @@ namespace sharp {
|
||||
imageType == ImageType::PDF;
|
||||
}
|
||||
|
||||
/*
|
||||
Does this image type support removal of safety limits?
|
||||
*/
|
||||
bool ImageTypeSupportsUnlimited(ImageType imageType) {
|
||||
return
|
||||
imageType == ImageType::JPEG ||
|
||||
imageType == ImageType::PNG ||
|
||||
imageType == ImageType::SVG ||
|
||||
imageType == ImageType::HEIF;
|
||||
}
|
||||
|
||||
/*
|
||||
Open an image from the given InputDescriptor (filesystem, compressed buffer, raw pixel data)
|
||||
*/
|
||||
@@ -362,8 +373,7 @@ namespace sharp {
|
||||
vips::VOption *option = VImage::option()
|
||||
->set("access", descriptor->access)
|
||||
->set("fail_on", descriptor->failOn);
|
||||
if (descriptor->unlimited &&
|
||||
(imageType == ImageType::SVG || imageType == ImageType::PNG || imageType == ImageType::JPEG)) {
|
||||
if (descriptor->unlimited && ImageTypeSupportsUnlimited(imageType)) {
|
||||
option->set("unlimited", TRUE);
|
||||
}
|
||||
if (imageType == ImageType::SVG || imageType == ImageType::PDF) {
|
||||
@@ -466,8 +476,7 @@ namespace sharp {
|
||||
vips::VOption *option = VImage::option()
|
||||
->set("access", descriptor->access)
|
||||
->set("fail_on", descriptor->failOn);
|
||||
if (descriptor->unlimited &&
|
||||
(imageType == ImageType::SVG || imageType == ImageType::PNG || imageType == ImageType::JPEG)) {
|
||||
if (descriptor->unlimited && ImageTypeSupportsUnlimited(imageType)) {
|
||||
option->set("unlimited", TRUE);
|
||||
}
|
||||
if (imageType == ImageType::SVG || imageType == ImageType::PDF) {
|
||||
|
||||
@@ -206,6 +206,11 @@ namespace sharp {
|
||||
*/
|
||||
bool ImageTypeSupportsPage(ImageType imageType);
|
||||
|
||||
/*
|
||||
Does this image type support removal of safety limits?
|
||||
*/
|
||||
bool ImageTypeSupportsUnlimited(ImageType imageType);
|
||||
|
||||
/*
|
||||
Open an image from the given InputDescriptor (filesystem, compressed buffer, raw pixel data)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user