mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-06-17 22:37:33 +02:00
Add IMGPROXY_PNG_UNLIMITED
and IMGPROXY_SVG_UNLIMITED
configs
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
### Add
|
### Add
|
||||||
- Add [IMGPROXY_ALWAYS_RASTERIZE_SVG](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_ALWAYS_RASTERIZE_SVG) config.
|
- Add [IMGPROXY_ALWAYS_RASTERIZE_SVG](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_ALWAYS_RASTERIZE_SVG) config.
|
||||||
|
- Add [IMGPROXY_PNG_UNLIMITED](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_PNG_UNLIMITED) and [IMGPROXY_SVG_UNLIMITED](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_SVG_UNLIMITED) configs.
|
||||||
|
|
||||||
### Change
|
### Change
|
||||||
- Respond with 404 when the bucket/container name or object key is empty in an S3, Google Cloud Storage, Azure Blob Storage, or OpenStack Object Storage (Swift) URL.
|
- Respond with 404 when the bucket/container name or object key is empty in an S3, Google Cloud Storage, Azure Blob Storage, or OpenStack Object Storage (Swift) URL.
|
||||||
|
@ -44,6 +44,8 @@ var (
|
|||||||
MaxAnimationFrameResolution int
|
MaxAnimationFrameResolution int
|
||||||
MaxSvgCheckBytes int
|
MaxSvgCheckBytes int
|
||||||
MaxRedirects int
|
MaxRedirects int
|
||||||
|
PngUnlimited bool
|
||||||
|
SvgUnlimited bool
|
||||||
AllowSecurityOptions bool
|
AllowSecurityOptions bool
|
||||||
|
|
||||||
JpegProgressive bool
|
JpegProgressive bool
|
||||||
@ -235,6 +237,8 @@ func Reset() {
|
|||||||
MaxAnimationFrameResolution = 0
|
MaxAnimationFrameResolution = 0
|
||||||
MaxSvgCheckBytes = 32 * 1024
|
MaxSvgCheckBytes = 32 * 1024
|
||||||
MaxRedirects = 10
|
MaxRedirects = 10
|
||||||
|
PngUnlimited = false
|
||||||
|
SvgUnlimited = false
|
||||||
AllowSecurityOptions = false
|
AllowSecurityOptions = false
|
||||||
|
|
||||||
JpegProgressive = false
|
JpegProgressive = false
|
||||||
@ -433,6 +437,9 @@ func Configure() error {
|
|||||||
configurators.Bool(&SanitizeSvg, "IMGPROXY_SANITIZE_SVG")
|
configurators.Bool(&SanitizeSvg, "IMGPROXY_SANITIZE_SVG")
|
||||||
configurators.Bool(&AlwaysRasterizeSvg, "IMGPROXY_ALWAYS_RASTERIZE_SVG")
|
configurators.Bool(&AlwaysRasterizeSvg, "IMGPROXY_ALWAYS_RASTERIZE_SVG")
|
||||||
|
|
||||||
|
configurators.Bool(&PngUnlimited, "IMGPROXY_PNG_UNLIMITED")
|
||||||
|
configurators.Bool(&SvgUnlimited, "IMGPROXY_SVG_UNLIMITED")
|
||||||
|
|
||||||
configurators.Bool(&AllowSecurityOptions, "IMGPROXY_ALLOW_SECURITY_OPTIONS")
|
configurators.Bool(&AllowSecurityOptions, "IMGPROXY_ALLOW_SECURITY_OPTIONS")
|
||||||
|
|
||||||
configurators.Bool(&JpegProgressive, "IMGPROXY_JPEG_PROGRESSIVE")
|
configurators.Bool(&JpegProgressive, "IMGPROXY_JPEG_PROGRESSIVE")
|
||||||
|
11
vips/vips.c
11
vips/vips.c
@ -64,9 +64,13 @@ vips_jpegload_go(void *buf, size_t len, int shrink, VipsImage **out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips_pngload_go(void *buf, size_t len, VipsImage **out)
|
vips_pngload_go(void *buf, size_t len, VipsImage **out, int unlimited)
|
||||||
{
|
{
|
||||||
return vips_pngload_buffer(buf, len, out, "access", VIPS_ACCESS_SEQUENTIAL, NULL);
|
return vips_pngload_buffer(
|
||||||
|
buf, len, out,
|
||||||
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
|
"unlimited", unlimited,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -87,7 +91,7 @@ vips_gifload_go(void *buf, size_t len, int pages, VipsImage **out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
vips_svgload_go(void *buf, size_t len, double scale, VipsImage **out)
|
vips_svgload_go(void *buf, size_t len, double scale, VipsImage **out, int unlimited)
|
||||||
{
|
{
|
||||||
// libvips limits the minimal scale to 0.001, so we have to scale down dpi
|
// libvips limits the minimal scale to 0.001, so we have to scale down dpi
|
||||||
// for lower scale values
|
// for lower scale values
|
||||||
@ -102,6 +106,7 @@ vips_svgload_go(void *buf, size_t len, double scale, VipsImage **out)
|
|||||||
"access", VIPS_ACCESS_SEQUENTIAL,
|
"access", VIPS_ACCESS_SEQUENTIAL,
|
||||||
"scale", scale,
|
"scale", scale,
|
||||||
"dpi", dpi,
|
"dpi", dpi,
|
||||||
|
"unlimited", unlimited,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,8 @@ var vipsConf struct {
|
|||||||
PngQuantize C.int
|
PngQuantize C.int
|
||||||
PngQuantizationColors C.int
|
PngQuantizationColors C.int
|
||||||
AvifSpeed C.int
|
AvifSpeed C.int
|
||||||
|
PngUnlimited C.int
|
||||||
|
SvgUnlimited C.int
|
||||||
}
|
}
|
||||||
|
|
||||||
var badImageErrRe = []*regexp.Regexp{
|
var badImageErrRe = []*regexp.Regexp{
|
||||||
@ -96,6 +98,8 @@ func Init() error {
|
|||||||
vipsConf.PngQuantize = gbool(config.PngQuantize)
|
vipsConf.PngQuantize = gbool(config.PngQuantize)
|
||||||
vipsConf.PngQuantizationColors = C.int(config.PngQuantizationColors)
|
vipsConf.PngQuantizationColors = C.int(config.PngQuantizationColors)
|
||||||
vipsConf.AvifSpeed = C.int(config.AvifSpeed)
|
vipsConf.AvifSpeed = C.int(config.AvifSpeed)
|
||||||
|
vipsConf.PngUnlimited = gbool(config.PngUnlimited)
|
||||||
|
vipsConf.SvgUnlimited = gbool(config.SvgUnlimited)
|
||||||
|
|
||||||
prometheus.AddGaugeFunc(
|
prometheus.AddGaugeFunc(
|
||||||
"vips_memory_bytes",
|
"vips_memory_bytes",
|
||||||
@ -327,13 +331,13 @@ func (img *Image) Load(imgdata *imagedata.ImageData, shrink int, scale float64,
|
|||||||
case imagetype.JPEG:
|
case imagetype.JPEG:
|
||||||
err = C.vips_jpegload_go(data, dataSize, C.int(shrink), &tmp)
|
err = C.vips_jpegload_go(data, dataSize, C.int(shrink), &tmp)
|
||||||
case imagetype.PNG:
|
case imagetype.PNG:
|
||||||
err = C.vips_pngload_go(data, dataSize, &tmp)
|
err = C.vips_pngload_go(data, dataSize, &tmp, vipsConf.PngUnlimited)
|
||||||
case imagetype.WEBP:
|
case imagetype.WEBP:
|
||||||
err = C.vips_webpload_go(data, dataSize, C.double(scale), C.int(pages), &tmp)
|
err = C.vips_webpload_go(data, dataSize, C.double(scale), C.int(pages), &tmp)
|
||||||
case imagetype.GIF:
|
case imagetype.GIF:
|
||||||
err = C.vips_gifload_go(data, dataSize, C.int(pages), &tmp)
|
err = C.vips_gifload_go(data, dataSize, C.int(pages), &tmp)
|
||||||
case imagetype.SVG:
|
case imagetype.SVG:
|
||||||
err = C.vips_svgload_go(data, dataSize, C.double(scale), &tmp)
|
err = C.vips_svgload_go(data, dataSize, C.double(scale), &tmp, vipsConf.SvgUnlimited)
|
||||||
case imagetype.HEIC, imagetype.AVIF:
|
case imagetype.HEIC, imagetype.AVIF:
|
||||||
err = C.vips_heifload_go(data, dataSize, &tmp, C.int(0))
|
err = C.vips_heifload_go(data, dataSize, &tmp, C.int(0))
|
||||||
case imagetype.TIFF:
|
case imagetype.TIFF:
|
||||||
|
@ -16,10 +16,10 @@ int gif_resolution_limit();
|
|||||||
int vips_health();
|
int vips_health();
|
||||||
|
|
||||||
int vips_jpegload_go(void *buf, size_t len, int shrink, VipsImage **out);
|
int vips_jpegload_go(void *buf, size_t len, int shrink, VipsImage **out);
|
||||||
int vips_pngload_go(void *buf, size_t len, VipsImage **out);
|
int vips_pngload_go(void *buf, size_t len, VipsImage **out, int unlimited);
|
||||||
int vips_webpload_go(void *buf, size_t len, double scale, int pages, VipsImage **out);
|
int vips_webpload_go(void *buf, size_t len, double scale, int pages, VipsImage **out);
|
||||||
int vips_gifload_go(void *buf, size_t len, int pages, VipsImage **out);
|
int 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);
|
int vips_svgload_go(void *buf, size_t len, double scale, VipsImage **out, int unlimited);
|
||||||
int vips_heifload_go(void *buf, size_t len, VipsImage **out, int thumbnail);
|
int vips_heifload_go(void *buf, size_t len, VipsImage **out, int thumbnail);
|
||||||
int vips_tiffload_go(void *buf, size_t len, VipsImage **out);
|
int vips_tiffload_go(void *buf, size_t len, VipsImage **out);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user