bfintal/bfi_thumb

Proportional image scaling

Opened this issue · 3 comments

zc parameter is not provided by bfi.

/thumb.php?src=/images/image.jpg&h=50&w=50&zc=2&q=90

It should work like at timthumb:
0 Resize to Fit specified dimensions (no cropping)
1 Crop and resize to best fit the dimensions (default)
2 Resize proportionally to fit entire image into specified dimensions, and add borders if required
3 Resize proportionally adjusting size of scaled image so there are no borders gaps

Thanks

@motylanogha I've written something to achieve what you need as I needed it too, it may contain some bugs (specially using ImageMagick as I didn't test that part). I've made a pull request for it, in the meanwhile you can test it from a fork I made to work on it https://github.com/gbonvehi/bfi_thumb

Cheers,
Guillermo

Hi gbonvehi, Thanks. Could you please explain shortly how this cropping works?
How can I choose the style of cropping?

Thanks.

Sure, however I may have understood wrong as I thought you wanted option zc=2 only. I haven't used timthumb before so maybe it's not the same behavior.
Basically I added two parameters to bfi_thumb, 'fit' and 'fit_color' which will allow you to fit an image inside boundaries and add borders as necessary.
Example parameters;
array( 'width' => 400, 'height' => 200, 'fit' => true )
array( 'width' => 400, 'height' => 200, 'fit' => true, 'fit_color' => '#000000' )
The first one will fit the image in 400x200 and add transparent background (it will output .png files) and the second one would add a black border if needed.

Edit: Forgot to add that it will center the image.