|
@@ -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")
|
|
|
|