Home > Mobile >  Resize to Specific Height and Width with pyvips
Resize to Specific Height and Width with pyvips

Time:09-30

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?

CodePudding user response:

The thumbnail operation in pyvips will resize to fit an area. For example:

thumb = pyvips.Image.thumbnail("some-file.jpg", 128)

Will load some-file.jpg and make a high-quality image that fits within 128x128 pixels.

Variations on thumbnail can load from strings, buffers or even pipes.

The libvips docs have a chapter on vipsthumbnail explaining how to use the (many) options.

  • Related