libvips / php-vips

php binding for libvips
MIT License
615 stars 25 forks source link

thumbnail_buffer width param not behaving as expected #186

Closed goldmerc closed 1 year ago

goldmerc commented 1 year ago

I'm still on v1 (1.0.10) of php-vips.

Vips installed using apt-get. I have version 8.9.1.

When I call VipsImage::thumbnail_buffer($source, $width, $params) on a landscape image, it behaves as expected. But if I try it on a portrait image, the height is set to $width and the width is set proportionally. So, instead of $width setting the width, for me it is setting the length, or whichever is longer of width and height.

Am I misunderstanding something?

Thanks,

Jonathan

mferrara commented 1 year ago

Disclaimer: I'm here looking at the issues because I'm running into my own issues, but having combed through the documentation quite a bit your issue here threw up an exception in my brain... (:D)

You may want to take a look at the auto-rotate documentation and see if that's having an effect. (https://www.libvips.org/API/8.7/Using-vipsthumbnail.md.html)

goldmerc commented 1 year ago

Thanks for the idea. But the image is not being rotated. It's simply being sized with the $width value used for the height instead of the width

jcupitt commented 1 year ago

Hi @goldmerc,

The main thumbnail docs are here:

https://www.libvips.org/API/current/libvips-resample.html#vips-thumbnail

It resizes to fit within a width x height box, with the optional height param defaulting to the value of width. If you only want to size by width, set height to a huge number, perhaps:

$thumb =Vips\Image.thumbnail("x.jpg", 1000, ["height" => 10000000]);
goldmerc commented 1 year ago

Thanks @jcupitt. It was exactly that! Really appreciate you consistent, fast support and a great product. You're the best!