Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Commit 53c35e3

Browse files
committed
Clearer focalpoint X/Y calculation
1 parent 667e7ea commit 53c35e3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

halfshell/image_processor.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,8 @@ func (ip *imageProcessor) resizeApply(img *Image, dimensions ImageDimensions) er
295295

296296
func (ip *imageProcessor) cropApply(img *Image, reqDimensions ImageDimensions, focalpoint Focalpoint) error {
297297
oldDimensions := img.GetDimensions()
298-
x := int(float64(oldDimensions.Width)*focalpoint.X - float64(reqDimensions.Width)*focalpoint.X)
299-
y := int(float64(oldDimensions.Height)*focalpoint.Y - float64(reqDimensions.Height)*focalpoint.Y)
298+
x := int(focalpoint.X * (float64(oldDimensions.Width) - float64(reqDimensions.Width)))
299+
y := int(focalpoint.Y * (float64(oldDimensions.Height) - float64(reqDimensions.Height)))
300300
w := reqDimensions.Width
301301
h := reqDimensions.Height
302302
return img.Wand.CropImage(w, h, x, y)

0 commit comments

Comments
 (0)