aboutsummaryrefslogtreecommitdiffstats
path: root/icat.go
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2026-06-11 21:14:40 -0700
committerRose Hogenson <rosehogenson@posteo.net>2026-06-11 21:14:40 -0700
commitb2b0ff935fa517fd235887ad66b55c07ff0994f9 (patch)
treee2f8ec9057b624b7cbd062806e9a1ad949f3fe72 /icat.go
parent5efde7b99a748cae7989f1f6e022bfced4a4b841 (diff)
downloadimgutil-b2b0ff935fa517fd235887ad66b55c07ff0994f9.tar.zst
Don't resize up every image
Diffstat (limited to 'icat.go')
-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)