rifanece / timthumb

Automatically exported from code.google.com/p/timthumb
0 stars 0 forks source link

add a "max" parameter #78

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Thumbnails are square, we all agree about that.
Anyway, it happens (a lot) that some applications, people, ... want
thumbnails to be generated with respect to ratio without cropping.

TimThumb provides that when omitting one of the units (width or height).
Anyway you still have to decide which unit you'll omit.
In 99% of the cases you take the higher unit and reduce it to exactly match
a requested maximum. Then you reduce the lower unit with this ratio.
Without this parameter users/developpers often need to do a first call to
getimagesize, then test which unit is the highest then call TimThumb with a
blank value for the other unit.
That work would be avoided if TimThumb handled a {max,limit,..} parameter.
As a benefit, that would work for remotely fetched files.

To be exhaustive, there is also another thing that a lot of application
using TimThumb do outside of it : test if the size of the image is lower
than the requested thumbnail then return the vanilla file.
If TimThumb would do that would be another pain done once for all.
As a benefit, that would work for remotely fetched files (bis)
I don't thing it would need a "reduce_even_if_smaller_than_requested_size"
parameter :)

thanks

Original issue reported on code.google.com by gibbo...@gmail.com on 24 Mar 2010 at 5:23

GoogleCodeExporter commented 8 years ago
This patch add the following feature which is IMHO a good start to the requested
feature :
This patch add two new parameters : w2 and h2.
Those parameter are taken into account if :
- crop=0
and
- one of "w" or "h" parameter has been omitted.

Then it does the following :
If those conditions are met a *kind of* "second pass" is done meaning it will 
apply
the new constraint on the first pass values.
To do that if factorized the "new w/h generation code" into a function and call 
it a
second time if conditions are met.

In a case like :
- resize the height to h and omit the width, thus preserving the ratio ...
the feature provided by the patch is the following :
- then resize the width to w if new width > w

Original comment by gibbo...@gmail.com on 26 Mar 2010 at 10:43

Attachments:

GoogleCodeExporter commented 8 years ago
How do I install this? Like, where does it go? Inside the timthumb.php file or 
in the same folder or what? I'm using classipress with wordpress and timthumb 
is part of one or the other and the cropping at the top is driving me nuts.
Thanks, Don

Original comment by d...@donmilton.com on 15 Aug 2010 at 5:42

GoogleCodeExporter commented 8 years ago
It's taken a while, but this is now added!

Use parameter zc = 2

Original comment by BinaryMoon on 6 Feb 2011 at 9:40