mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-02-07 11:36:25 +02:00
MaxGifFrames => MaxAnimationFrames
This commit is contained in:
parent
e4b8332752
commit
5553cee501
21
config.go
21
config.go
@ -137,10 +137,10 @@ type config struct {
|
||||
MaxClients int
|
||||
TTL int
|
||||
|
||||
MaxSrcDimension int
|
||||
MaxSrcResolution int
|
||||
MaxSrcFileSize int
|
||||
MaxGifFrames int
|
||||
MaxSrcDimension int
|
||||
MaxSrcResolution int
|
||||
MaxSrcFileSize int
|
||||
MaxAnimationFrames int
|
||||
|
||||
JpegProgressive bool
|
||||
PngInterlaced bool
|
||||
@ -215,7 +215,7 @@ var conf = config{
|
||||
Concurrency: runtime.NumCPU() * 2,
|
||||
TTL: 3600,
|
||||
MaxSrcResolution: 16800000,
|
||||
MaxGifFrames: 1,
|
||||
MaxAnimationFrames: 1,
|
||||
SignatureSize: 32,
|
||||
PngQuantizationColors: 256,
|
||||
Quality: 80,
|
||||
@ -259,7 +259,12 @@ func configure() {
|
||||
intEnvConfig(&conf.MaxSrcDimension, "IMGPROXY_MAX_SRC_DIMENSION")
|
||||
megaIntEnvConfig(&conf.MaxSrcResolution, "IMGPROXY_MAX_SRC_RESOLUTION")
|
||||
intEnvConfig(&conf.MaxSrcFileSize, "IMGPROXY_MAX_SRC_FILE_SIZE")
|
||||
intEnvConfig(&conf.MaxGifFrames, "IMGPROXY_MAX_GIF_FRAMES")
|
||||
|
||||
if _, ok := os.LookupEnv("IMGPROXY_MAX_GIF_FRAMES"); ok {
|
||||
logWarning("`IMGPROXY_MAX_GIF_FRAMES` is deprecated and will be removed in future versions. Use `IMGPROXY_MAX_ANIMATION_FRAMES` instead")
|
||||
intEnvConfig(&conf.MaxAnimationFrames, "IMGPROXY_MAX_GIF_FRAMES")
|
||||
}
|
||||
intEnvConfig(&conf.MaxAnimationFrames, "IMGPROXY_MAX_ANIMATION_FRAMES")
|
||||
|
||||
boolEnvConfig(&conf.JpegProgressive, "IMGPROXY_JPEG_PROGRESSIVE")
|
||||
boolEnvConfig(&conf.PngInterlaced, "IMGPROXY_PNG_INTERLACED")
|
||||
@ -388,8 +393,8 @@ func configure() {
|
||||
logFatal("Max src file size should be greater than or equal to 0, now - %d\n", conf.MaxSrcFileSize)
|
||||
}
|
||||
|
||||
if conf.MaxGifFrames <= 0 {
|
||||
logFatal("Max GIF frames should be greater than 0, now - %d\n", conf.MaxGifFrames)
|
||||
if conf.MaxAnimationFrames <= 0 {
|
||||
logFatal("Max animation frames should be greater than 0, now - %d\n", conf.MaxAnimationFrames)
|
||||
}
|
||||
|
||||
if conf.PngQuantizationColors < 2 {
|
||||
|
@ -43,11 +43,11 @@ imgproxy protects you from so-called image bombs. Here is how you can specify ma
|
||||
* `IMGPROXY_MAX_SRC_RESOLUTION`: the maximum resolution of the source image, in megapixels. Images with larger actual size will be rejected. Default: `16.8`;
|
||||
* `IMGPROXY_MAX_SRC_FILE_SIZE`: the maximum size of the source image, in bytes. Images with larger file size will be rejected. When `0`, file size check is disabled. Default: `0`;
|
||||
|
||||
imgproxy can process animated GIFs, but since this operation is pretty heavy, only one frame is processed by default. You can increase the maximum of GIF frames to process with the following variable:
|
||||
imgproxy can process animated images (GIF, WebP), but since this operation is pretty heavy, only one frame is processed by default. You can increase the maximum of animation frames to process with the following variable:
|
||||
|
||||
* `IMGPROXY_MAX_GIF_FRAMES`: the maximum of animated GIF frames to being processed. Default: `1`.
|
||||
* `IMGPROXY_MAX_ANIMATION_FRAMES`: the maximum of animated image frames to being processed. Default: `1`.
|
||||
|
||||
**Note:** imgproxy summarizes all GIF frames resolutions while checking source image resolution.
|
||||
**Note:** imgproxy summarizes all frames resolutions while checking source image resolution.
|
||||
|
||||
You can also specify a secret to enable authorization with the HTTP `Authorization` header for use in production environments:
|
||||
|
||||
|
@ -360,7 +360,7 @@ func transformAnimated(ctx context.Context, img *vipsImage, data []byte, po *pro
|
||||
return err
|
||||
}
|
||||
|
||||
framesCount := minInt(img.Height()/frameHeight, conf.MaxGifFrames)
|
||||
framesCount := minInt(img.Height()/frameHeight, conf.MaxAnimationFrames)
|
||||
|
||||
// Double check dimensions because animated image has many frames
|
||||
if err := checkDimensions(imgWidth, frameHeight*framesCount); err != nil {
|
||||
@ -489,7 +489,7 @@ func processImage(ctx context.Context) ([]byte, context.CancelFunc, error) {
|
||||
po.Width, po.Height = 0, 0
|
||||
}
|
||||
|
||||
animationSupport := conf.MaxGifFrames > 1 && vipsSupportAnimation(imgtype) && vipsSupportAnimation(po.Format)
|
||||
animationSupport := conf.MaxAnimationFrames > 1 && vipsSupportAnimation(imgtype) && vipsSupportAnimation(po.Format)
|
||||
|
||||
pages := 1
|
||||
if animationSupport {
|
||||
|
Loading…
x
Reference in New Issue
Block a user