image_size.go 463 B

1234567891011121314151617
  1. package security
  2. func CheckDimensions(width, height, frames int, opts Options) error {
  3. frames = max(frames, 1)
  4. if frames > 1 && opts.MaxAnimationFrameResolution > 0 {
  5. if width*height > opts.MaxAnimationFrameResolution {
  6. return newImageResolutionError("Source image frame resolution is too big")
  7. }
  8. } else {
  9. if width*height*frames > opts.MaxSrcResolution {
  10. return newImageResolutionError("Source image resolution is too big")
  11. }
  12. }
  13. return nil
  14. }