Expose unlimited option for HEIF input

This commit is contained in:
Lovell Fuller
2022-09-05 09:15:10 +01:00
parent 31c1cfb049
commit c1393daa70
5 changed files with 22 additions and 8 deletions

View File

@@ -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) {

View File

@@ -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)
*/