Skip to content

Commit

Permalink
fix: face rec
Browse files Browse the repository at this point in the history
  • Loading branch information
xxxsen committed Jul 7, 2024
1 parent 75e9a3c commit 0ae6b67
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ func CutImageWithFaceRec(img image.Image) (image.Image, error) {
selectedFace := face.FindMaxFace(fs)
if img.Bounds().Dx() < img.Bounds().Dy() {
//如果图片宽高比小于预期, 那么这里需要按竖屏图进行裁剪
return cutVerticalImage(img, selectedFace.Rectangle.Dy()/2, defaultAspectRatio)
return cutVerticalImage(img, selectedFace.Rectangle.Min.Y+selectedFace.Rectangle.Dy()/2, defaultAspectRatio)
} else if img.Bounds().Dx() > img.Bounds().Dy() {
return cutHorizontalImage(img, selectedFace.Rectangle.Dx()/2, defaultAspectRatio)
return cutHorizontalImage(img, selectedFace.Rectangle.Min.X+selectedFace.Rectangle.Dx()/2, defaultAspectRatio)
} else {
return cutSquareImage(img, selectedFace.Rectangle.Dx()/2, defaultAspectRatio)
}
Expand Down

0 comments on commit 0ae6b67

Please sign in to comment.