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

Method getImageSize

processing/processing.go:204–222  ·  view source on GitHub ↗

getImageSize returns the width and height of the image, taking into account orientation and animation.

(img *vips.Image)

Source from the content-addressed store, hash-verified

202// getImageSize returns the width and height of the image, taking into account
203// orientation and animation.
204func (p *Processor) getImageSize(img *vips.Image) (int, int, int) {
205 width, height := img.Width(), img.Height()
206 frames := 1
207
208 if img.IsAnimated() {
209 // Animated images contain multiple frames, and libvips loads them stacked vertically.
210 // We want to return the size of a single frame
211 height = img.PageHeight()
212 frames = img.PagesLoaded()
213 }
214
215 // If the image is rotated by 90 or 270 degrees, we need to swap width and height
216 orientation := img.Orientation()
217 if orientation == 5 || orientation == 6 || orientation == 7 || orientation == 8 {
218 width, height = height, width
219 }
220
221 return width, height, frames
222}
223
224// Returns true if image should not be processed as usual
225func (p *Processor) shouldSkipStandardProcessing(

Callers 2

ProcessImageMethod · 0.95
checkImageSizeMethod · 0.95

Calls 6

IsAnimatedMethod · 0.80
PageHeightMethod · 0.80
PagesLoadedMethod · 0.80
OrientationMethod · 0.80
WidthMethod · 0.45
HeightMethod · 0.45

Tested by

no test coverage detected