MCPcopy Index your code
hub / github.com/cshum/imagor / CheckResolution

Method CheckResolution

processor/vipsprocessor/processor.go:506–516  ·  view source on GitHub ↗

CheckResolution check image resolution for image bomb prevention

(img *vips.Image, err error)

Source from the content-addressed store, hash-verified

504
505// CheckResolution check image resolution for image bomb prevention
506func (v *Processor) CheckResolution(img *vips.Image, err error) (*vips.Image, error) {
507 if err != nil || img == nil {
508 return img, err
509 }
510 if !v.Unlimited && (img.Width() > v.MaxWidth || img.PageHeight() > v.MaxHeight ||
511 (img.Width()*img.Height()) > v.MaxResolution) {
512 img.Close()
513 return nil, imagor.ErrMaxResolutionExceeded
514 }
515 return img, nil
516}
517
518func isMultiPage(blob *imagor.Blob, n, page int) bool {
519 return blob != nil && (blob.SupportsAnimation() || blob.BlobType() == imagor.BlobTypePDF) && ((n != 1 && n != 0) || (page != 1 && page != 0))

Callers 5

applyTransformationsMethod · 0.95
exportMethod · 0.95
NewThumbnailMethod · 0.95
newThumbnailFallbackMethod · 0.95
NewImageMethod · 0.95

Implementers 4

cacherProcessorimagor_test.go
Processorprocessor/vipsprocessor/processor.go
testProcessorserver/server_test.go
slowTestProcessorserver/server_test.go

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected