python - Image Resize with PIL -


input image size dimension (a,b)

output image size (c,d) c> =k , d >= k

example: input image(900,600) minimum dimension k= 400

then output image should (600,400)

is there function pil.image achieve goal?

you can't use usual "thumbnail", designed more usual requirement of having maximum dimension. instead can use "resize" method, after having computed wanted size. like:

if image.width >= k , image.height >= k:     if image.height < image.width:         factor = float(k) / image.height     else:         factor = float(k) / image.width     image.resize((image.width* factor, image.height * factor)) 

Comments

Popular posts from this blog

c - zlib and gdi32 with OpenSSL? -

java - inputmismatch exception -

ios - Align baselines with characters in large line heights with Text Kit -