1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-02-07 11:36:25 +02:00

Fix scale-on-load of big SVGs

This commit is contained in:
DarthSim 2021-02-22 21:57:19 +06:00
parent bad20a3f02
commit 07686d4411

16
vips.c
View File

@ -168,7 +168,21 @@ vips_gifload_go(void *buf, size_t len, int pages, VipsImage **out) {
int
vips_svgload_go(void *buf, size_t len, double scale, VipsImage **out) {
#if VIPS_SUPPORT_SVG
return vips_svgload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, "scale", scale, NULL);
// libvips limits the minimal scale to 0.001, so we have to scale down dpi
// for lower scale values
double dpi = 72.0;
if (scale < 0.001) {
dpi *= VIPS_MAX(scale / 0.001, 0.001);
scale = 0.001;
}
return vips_svgload_buffer(
buf, len, out,
"access", VIPS_ACCESS_SEQUENTIAL,
"scale", scale,
"dpi", dpi,
NULL
);
#else
vips_error("vips_svgload_go", "Loading SVG is not supported (libvips 8.5+ reuired)");
return 1;