2

I'm using vipsthumbnail to resize images via the command line.

I would like to know if there is a way to resize an image and ignore its aspect ratio, so that no matter what size if I passed 5x500 I would get a 5px by 500px image.

I can't fine anything in the documentation.

I'm using the lib on macOS.

nkkollaw
  • 1,947
  • 1
  • 19
  • 29

1 Answers1

2

From libvips 8.6, vipsthumbnail supports imagemagick-style size specifications. For example:

vipsthumbnail k2.jpg --size "50x50!"

will resize to 50x50 pixels whatever the size of the input image. There's a chapter in the docs about using vipsthumbnail:

http://libvips.github.io/libvips/API/current/Using-vipsthumbnail.md.html

jcupitt
  • 10,213
  • 2
  • 23
  • 39
  • Is there any method for php library for ignore its aspect ratio in vips resize funcion? – Vinay Kapoor Aug 31 '20 at 08:40
  • Try `['size' => 'force']`. – jcupitt Aug 31 '20 at 09:54
  • $im = $im->resize($ratio, ['size' => 'force']); I try above one, it gives me error no property named `size' – Vinay Kapoor Aug 31 '20 at 10:27
  • You need `thumbnail`. Try `$image = Vips\Image::thumbnail('some/filename.tif', 50, ['height' => 50, 'size' => 'force']);`. Don't use `resize` unless you have to, it's much slower, but if you must use it, there's a `vscale` parameter to set the vertical scaling separately. Check the docs: https://libvips.github.io/libvips/API/current/libvips-resample.html#vips-resize – jcupitt Aug 31 '20 at 10:47