I find this answer, and I want to use pyvips to resize images. In the mentioned answer and the official documentation image resized by scale. However, I want to resize the image to a specific height and width. Is there any way to achieve this with pyvips?
The thumbnail operation in pyvips will load an image to fit a box, for example:
thumb = pyvips.Image.thumbnail("some-file.jpg", 128)
Will load some-file.jpg
and make an image that fits within 128x128 pixels. Variations on thumbnail
can load from strings, buffers or pipes, load to fit other boxes, check the chapter on vipsthumbnail for details.
If you already have a loaded image, thumbnail_image
will resize to pixel dimensions in the same way, but can be quite a bit slower.