Improve error message for SVG render above limit #3167

This commit is contained in:
Lovell Fuller
2022-04-04 14:20:04 +01:00
parent 926572b41e
commit 5d36f5f699
3 changed files with 24 additions and 1 deletions

View File

@@ -241,8 +241,10 @@ class PipelineWorker : public Napi::AsyncWorker {
// Reload SVG file
image = VImage::svgload(const_cast<char*>(baton->input->file.data()), option);
}
sharp::SetDensity(image, baton->input->density);
if (image.width() > 32767 || image.height() > 32767) {
throw vips::VError("Input SVG image will exceed 32767x32767 pixel limit when scaled");
}
} else if (inputImageType == sharp::ImageType::PDF) {
option->set("n", baton->input->pages);
option->set("page", baton->input->page);
@@ -260,6 +262,10 @@ class PipelineWorker : public Napi::AsyncWorker {
sharp::SetDensity(image, baton->input->density);
}
} else {
if (inputImageType == sharp::ImageType::SVG && (image.width() > 32767 || image.height() > 32767)) {
throw vips::VError("Input SVG image exceeds 32767x32767 pixel limit");
}
}
// Any pre-shrinking may already have been done