getImageSize returns the width and height of the image, taking into account orientation and animation.
(img *vips.Image)
| 202 | // getImageSize returns the width and height of the image, taking into account |
| 203 | // orientation and animation. |
| 204 | func (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 |
| 225 | func (p *Processor) shouldSkipStandardProcessing( |
no test coverage detected