Skip to content

example resize

John Cupitt edited this page Apr 22, 2020 · 4 revisions

This resizes an image to within a bounding box. Make the first parameter very large to just scale to height.

def resize(filein, fileout, maxw, maxh):
    out = pyvips.Image.thumbnail(filein, maxw, height=maxh)
    out.write_to_file(fileout, Q=95)

It uses the thumbnail function of vips - which has a lot of features (and doesn't just make thumbnails).

Clone this wiki locally