aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--icat.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/icat.go b/icat.go
index 9382332..f7f31df 100644
--- a/icat.go
+++ b/icat.go
@@ -231,7 +231,9 @@ func medianCut(img image.Image) color.Palette {
return palette
}
-func printImg(img image.Image, x, y, pixelX, pixelY int) error {
+func printImg(img image.Image, maxX, maxY, pixelX, pixelY int) error {
+ x := min(img.Bounds().Dx(), maxX)
+ y := min(img.Bounds().Dy(), maxY)
// Try not to stretch the image.
if y == 0 || x != 0 && img.Bounds().Dy()*x <= img.Bounds().Dx()*y*pixelY/pixelX {
y = divRound(img.Bounds().Dy()*x*pixelX, img.Bounds().Dx()*pixelY)