MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / checkImageSize

Method checkImageSize

processing/processing.go:185–200  ·  view source on GitHub ↗

checkImageSize checks the image dimensions and number of frames against security options. It returns the image width, height and a security check error, if any.

(
	img *vips.Image,
	imgtype imagetype.Type,
	po ProcessingOptions,
)

Source from the content-addressed store, hash-verified

183// checkImageSize checks the image dimensions and number of frames against security options.
184// It returns the image width, height and a security check error, if any.
185func (p *Processor) checkImageSize(
186 img *vips.Image,
187 imgtype imagetype.Type,
188 po ProcessingOptions,
189) (int, int, error) {
190 width, height, frames := p.getImageSize(img)
191
192 if imgtype.IsVector() {
193 // We don't check vector image dimensions as we can render it in any size
194 return width, height, nil
195 }
196
197 err := p.securityChecker.CheckDimensions(po.Options, width, height, frames)
198
199 return width, height, err
200}
201
202// getImageSize returns the width and height of the image, taking into account
203// orientation and animation.

Callers 3

prepareWatermarkMethod · 0.95
ProcessImageMethod · 0.95

Calls 3

getImageSizeMethod · 0.95
IsVectorMethod · 0.80
CheckDimensionsMethod · 0.80

Tested by

no test coverage detected