image_size.go 522 B

123456789101112131415161718192021
  1. package security
  2. import (
  3. "github.com/imgproxy/imgproxy/v3/imath"
  4. )
  5. func CheckDimensions(width, height, frames int, opts Options) error {
  6. frames = imath.Max(frames, 1)
  7. if frames > 1 && opts.MaxAnimationFrameResolution > 0 {
  8. if width*height > opts.MaxAnimationFrameResolution {
  9. return newImageResolutionError("Source image frame resolution is too big")
  10. }
  11. } else {
  12. if width*height*frames > opts.MaxSrcResolution {
  13. return newImageResolutionError("Source image resolution is too big")
  14. }
  15. }
  16. return nil
  17. }