loadAndProcess loads the image from blob and applies all transformations
( ctx context.Context, blob *imagor.Blob, p imagorpath.Params, load imagor.LoadFunc, )
| 272 | |
| 273 | // loadAndProcess loads the image from blob and applies all transformations |
| 274 | func (v *Processor) loadAndProcess( |
| 275 | ctx context.Context, blob *imagor.Blob, p imagorpath.Params, load imagor.LoadFunc, |
| 276 | ) (*vips.Image, error) { |
| 277 | if c, ok := parseColorImage(p.Image); ok { |
| 278 | w, h := p.Width, p.Height |
| 279 | if w <= 0 && h <= 0 { |
| 280 | w, h = 1, 1 |
| 281 | } else if w <= 0 { |
| 282 | w = h |
| 283 | } else if h <= 0 { |
| 284 | h = w |
| 285 | } |
| 286 | if !v.Unlimited && w*h > v.MaxResolution { |
| 287 | return nil, imagor.ErrMaxResolutionExceeded |
| 288 | } |
| 289 | if w > v.MaxWidth { |
| 290 | w = v.MaxWidth |
| 291 | } |
| 292 | if h > v.MaxHeight { |
| 293 | h = v.MaxHeight |
| 294 | } |
| 295 | img, err := newColorImage(w, h, c) |
| 296 | if err != nil { |
| 297 | return nil, WrapErr(err) |
| 298 | } |
| 299 | if v.Debug { |
| 300 | v.Logger.Debug("color-image", |
| 301 | zap.Int("width", w), |
| 302 | zap.Int("height", h), |
| 303 | zap.Any("color", c)) |
| 304 | } |
| 305 | // thumbnail=true: image is already at target size, skip resize/crop |
| 306 | if err := v.applyTransformations(ctx, img, p, load, true, false, false, nil); err != nil { |
| 307 | img.Close() |
| 308 | return nil, WrapErr(err) |
| 309 | } |
| 310 | return img, nil |
| 311 | } |
| 312 | |
| 313 | var ( |
| 314 | thumbnailNotSupported bool |
| 315 | upscale = true |
| 316 | stretch = p.Stretch |
| 317 | thumbnail = false |
| 318 | orient int |
| 319 | img *vips.Image |
| 320 | maxN = v.MaxAnimationFrames |
| 321 | page = 1 |
| 322 | dpi = 0 |
| 323 | err error |
| 324 | ) |
| 325 | if p.Trim || p.VFlip || p.FullFitIn || p.AdaptiveFitIn { |
| 326 | thumbnailNotSupported = true |
| 327 | } |
| 328 | // When a detector is configured, load the full-resolution source so detection |
| 329 | // runs before any crop. Without this, Smart=true triggers NewThumbnail with |
| 330 | // InterestingAttention which decodes + attention-crops in one libvips call, |
| 331 | // leaving only the already-cropped thumbnail for detection. |
no test coverage detected