mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-24 15:52:38 +02:00
add boundaries for autocrop to allow split then crop
This commit is contained in:
parent
2442f2edc7
commit
51f62588c2
@ -8,9 +8,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Lookup for margin and crop
|
// Lookup for margin and crop
|
||||||
func AutoCrop(img image.Image, cutRatioLeft, cutRatioUp, cutRatioRight, cutRatioBottom int) gift.Filter {
|
func AutoCrop(img image.Image, bounds image.Rectangle, cutRatioLeft, cutRatioUp, cutRatioRight, cutRatioBottom int) gift.Filter {
|
||||||
return gift.Crop(
|
return gift.Crop(
|
||||||
findMarging(img, cutRatioOptions{cutRatioLeft, cutRatioUp, cutRatioRight, cutRatioBottom}),
|
findMargin(img, bounds, cutRatioOptions{cutRatioLeft, cutRatioUp, cutRatioRight, cutRatioBottom}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,8 +25,8 @@ type cutRatioOptions struct {
|
|||||||
Left, Up, Right, Bottom int
|
Left, Up, Right, Bottom int
|
||||||
}
|
}
|
||||||
|
|
||||||
func findMarging(img image.Image, cutRatio cutRatioOptions) image.Rectangle {
|
func findMargin(img image.Image, bounds image.Rectangle, cutRatio cutRatioOptions) image.Rectangle {
|
||||||
imgArea := img.Bounds()
|
imgArea := bounds
|
||||||
|
|
||||||
LEFT:
|
LEFT:
|
||||||
for x := imgArea.Min.X; x < imgArea.Max.X; x++ {
|
for x := imgArea.Min.X; x < imgArea.Max.X; x++ {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user