1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-12-23 22:11:10 +02:00
Files
imgproxy/security/options.go
Victor Sokolov f8133cd0b1 IMG-57: isSecurityOptionAllowed; shared parse fns (#1528)
* isSecurityOptionAllowed; shared parse fns

* We are not the same
2025-09-18 20:03:41 +06:00

28 lines
772 B
Go

package security
// Security options (part of processing options)
type Options struct {
MaxSrcResolution int
MaxSrcFileSize int
MaxAnimationFrames int
MaxAnimationFrameResolution int
MaxResultDimension int
}
// CheckDimensions checks if the given dimensions are within the allowed limits
func (o *Options) CheckDimensions(width, height, frames int) error {
frames = max(frames, 1)
if frames > 1 && o.MaxAnimationFrameResolution > 0 {
if width*height > o.MaxAnimationFrameResolution {
return newImageResolutionError("Source image frame resolution is too big")
}
} else {
if width*height*frames > o.MaxSrcResolution {
return newImageResolutionError("Source image resolution is too big")
}
}
return nil
}