v0.0.458 revert 457 and fix ObjectFitImage
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m49s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m49s
This commit is contained in:
@@ -234,11 +234,15 @@ func ObjectFitImage(img image.Image, bbw float64, bbh float64, fit ImageFit, fil
|
||||
|
||||
// we scale the bounding box by fac (both dimension the same amount, to keep the bounding-box ratio)
|
||||
|
||||
// [ow|oh] ==> size of output image (same ratio as bounding box [bbw|bbh])
|
||||
|
||||
ow := int(math.Round(bbw * facOut))
|
||||
oh := int(math.Round(bbh * facOut))
|
||||
|
||||
facScale := mathext.Min(float64(ow)/float64(iw), float64(oh)/float64(ih))
|
||||
|
||||
// [dw|dh] ==> size of destination rect (where to draw source in output image) (same ratio as input image [iw|ih])
|
||||
|
||||
dw := int(math.Round(float64(iw) * facScale))
|
||||
dh := int(math.Round(float64(ih) * facScale))
|
||||
|
||||
@@ -248,11 +252,11 @@ func ObjectFitImage(img image.Image, bbw float64, bbh float64, fit ImageFit, fil
|
||||
if fit == ImageFitContainCenter {
|
||||
destBounds = image.Rect((ow-dw)/2, (oh-dh)/2, (ow-dw)/2+dw, (oh-dh)/2+dh)
|
||||
} else if fit == ImageFitContainTopLeft {
|
||||
destBounds = image.Rect(0, 0, iw, dh)
|
||||
destBounds = image.Rect(0, 0, dw, dh)
|
||||
} else if fit == ImageFitContainTopRight {
|
||||
destBounds = image.Rect(ow-iw, 0, ow, dh)
|
||||
destBounds = image.Rect(ow-dw, 0, dw, dh)
|
||||
} else if fit == ImageFitContainBottomLeft {
|
||||
destBounds = image.Rect(0, oh-dh, iw, oh)
|
||||
destBounds = image.Rect(0, oh-dh, dw, oh)
|
||||
} else if fit == ImageFitContainBottomRight {
|
||||
destBounds = image.Rect(ow-dw, oh-dh, ow, oh)
|
||||
}
|
||||
|
Reference in New Issue
Block a user