Skip to content

Commit 63e1397

Browse files
committed
Do not resize on 0 h or h returned from termsize
1 parent 1aea91f commit 63e1397

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

print_image.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ func PrintImage(img *image.Image, filename string, imageSize int64) error {
7777
img2 = resize.Resize(uint(size), 0, img2, resize.NearestNeighbor)
7878
case 'y':
7979
img2 = resize.Resize(0, uint(size), img2, resize.NearestNeighbor)
80+
case '0':
81+
// Do nothing
8082
}
8183

8284
newWidth := img2.Bounds().Max.X

resize_constraints.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ func resizeConstraints(imageBounds image.Rectangle, maxHeight, maxWidth int) (si
88
imgHeight := imageBounds.Dy()
99
imgWidth := imageBounds.Dx()
1010

11+
if maxHeight == 0 || maxWidth == 0 {
12+
return 0, '0' // Don't resize
13+
}
14+
1115
if imgHeight <= maxHeight && imgWidth <= maxWidth {
1216
return 0, '0' // Don't resize
1317
}

0 commit comments

Comments
 (0)