mirror of
https://github.com/imgproxy/imgproxy.git
synced 2025-03-17 20:17:48 +02:00
Don't fail if smart crop is not supported but requested
This commit is contained in:
parent
6f889a14da
commit
e4b8332752
17
process.go
17
process.go
@ -8,6 +8,8 @@ import (
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
const msgSmartCropNotSupported = "Smart crop is not supported by used version of libvips"
|
||||
|
||||
func extractMeta(img *vipsImage) (int, int, int, bool) {
|
||||
width := img.Width()
|
||||
height := img.Height()
|
||||
@ -459,10 +461,6 @@ func processImage(ctx context.Context) ([]byte, context.CancelFunc, error) {
|
||||
data := getImageData(ctx).Bytes()
|
||||
imgtype := getImageType(ctx)
|
||||
|
||||
if po.Gravity.Type == gravitySmart && !vipsSupportSmartcrop {
|
||||
return nil, func() {}, errSmartCropNotSupported
|
||||
}
|
||||
|
||||
if po.Format == imageTypeUnknown {
|
||||
if vipsTypeSupportSave[imgtype] {
|
||||
po.Format = imgtype
|
||||
@ -471,6 +469,17 @@ func processImage(ctx context.Context) ([]byte, context.CancelFunc, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if !vipsSupportSmartcrop {
|
||||
if po.Gravity.Type == gravitySmart {
|
||||
logWarning(msgSmartCropNotSupported)
|
||||
po.Gravity.Type = gravityCenter
|
||||
}
|
||||
if po.Crop.Gravity.Type == gravitySmart {
|
||||
logWarning(msgSmartCropNotSupported)
|
||||
po.Crop.Gravity.Type = gravityCenter
|
||||
}
|
||||
}
|
||||
|
||||
if po.Resize == resizeCrop {
|
||||
logWarning("`crop` resizing type is deprecated and will be removed in future versions. Use `crop` processing option instead")
|
||||
|
||||
|
3
vips.go
3
vips.go
@ -9,7 +9,6 @@ package main
|
||||
import "C"
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"math"
|
||||
"os"
|
||||
"runtime"
|
||||
@ -27,8 +26,6 @@ var (
|
||||
vipsTypeSupportSave = make(map[imageType]bool)
|
||||
|
||||
watermark *vipsImage
|
||||
|
||||
errSmartCropNotSupported = errors.New("Smart crop is not supported by used version of libvips")
|
||||
)
|
||||
|
||||
var vipsConf struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user