ref: d68ebdcbe4acc103eed7f146350a86a8d5255cfa
parent: e432f766e0589685a77ac9f8b0a84be64299f68e
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Sep 3 18:49:04 EDT 2020
preserve aspect if either -x or -y was specified
--- a/resample.c
+++ b/resample.c
@@ -96,9 +96,15 @@
}
w = Dx(a->r);
h = Dy(a->r);
- ow = wp ? w*ow/100.0 : w;
- oh = hp ? h*oh/100.0 : h;
- if(w < 1 || h < 1)
+ if(wp)
+ ow = w*ow/100.0;
+ if(hp)
+ oh = h*oh/100.0;
+ if(oh == 0)
+ oh = ow*h/w;
+ if(ow == 0)
+ ow = oh*w/h;
+ if(ow < 1 || oh < 1)
sysfatal("invalid size: %dx%d", ow, oh);
bp = 3;
n = w*h*bp;