Skip to content

example resize

Kirk Martinez edited this page Sep 19, 2019 · 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): im = pyvips.Image.new_from_file(filein, access="sequential") out = pyvips.Image.thumbnail(filein, maxw, height=maxh) out.write_to_file(fileout , Q=95) ''' it uses the thumbnail thumbnail function of vips - which has a lot of features (and doesn't just make thumbnails)

Clone this wiki locally