@ -256,9 +256,19 @@ func extractOrEmbedImage(image *C.VipsImage, o Options) (*C.VipsImage, error) {
switch {
switch {
case o . Gravity == GravitySmart , o . SmartCrop :
case o . Gravity == GravitySmart , o . SmartCrop :
image , err = vipsSmartCrop ( image , o . Width , o . Height )
// it's already at an appropriate size, return immediately
if inWidth <= o . Width && inHeight <= o . Height {
break
}
width := int ( math . Min ( float64 ( inWidth ) , float64 ( o . Width ) ) )
height := int ( math . Min ( float64 ( inHeight ) , float64 ( o . Height ) ) )
image , err = vipsSmartCrop ( image , width , height )
break
break
case o . Crop :
case o . Crop :
// it's already at an appropriate size, return immediately
if inWidth <= o . Width && inHeight <= o . Height {
break
}
width := int ( math . Min ( float64 ( inWidth ) , float64 ( o . Width ) ) )
width := int ( math . Min ( float64 ( inWidth ) , float64 ( o . Width ) ) )
height := int ( math . Min ( float64 ( inHeight ) , float64 ( o . Height ) ) )
height := int ( math . Min ( float64 ( inHeight ) , float64 ( o . Height ) ) )
left , top := calculateCrop ( inWidth , inHeight , o . Width , o . Height , o . Gravity )
left , top := calculateCrop ( inWidth , inHeight , o . Width , o . Height , o . Gravity )