NewImage creates new Image from imagor.Blob
(ctx context.Context, blob *imagor.Blob, n, page int, dpi int)
| 412 | |
| 413 | // NewImage creates new Image from imagor.Blob |
| 414 | func (v *Processor) NewImage(ctx context.Context, blob *imagor.Blob, n, page int, dpi int) (*vips.Image, error) { |
| 415 | var options = &vips.LoadOptions{} |
| 416 | if dpi > 0 { |
| 417 | options.Dpi = dpi |
| 418 | } |
| 419 | options.Unlimited = v.Unlimited && unlimitedSupportedByLoader(blob) |
| 420 | if isMultiPage(blob, n, page) { |
| 421 | applyMultiPageOptions(options, n, page) |
| 422 | img, err := v.CheckResolution(v.newImageFromBlob(ctx, blob, options)) |
| 423 | if err != nil { |
| 424 | return nil, WrapErr(err) |
| 425 | } |
| 426 | // reload image to restrict frames loaded |
| 427 | if n > 1 || page > 1 { |
| 428 | n, page = recalculateImage(img, n, page) |
| 429 | return v.NewImage(ctx, blob, -n, -page, dpi) |
| 430 | } |
| 431 | return img, nil |
| 432 | } |
| 433 | img, err := v.CheckResolution(v.newImageFromBlob(ctx, blob, options)) |
| 434 | if err != nil { |
| 435 | return nil, WrapErr(err) |
| 436 | } |
| 437 | return img, nil |
| 438 | } |
| 439 | |
| 440 | // Thumbnail handles thumbnail operation |
| 441 | func (v *Processor) Thumbnail( |
no test coverage detected