oseawey / timthumb

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

Tweaking #93

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
1. You are using file command or PECL FileInfo to find mime type. There is
PHP function "getimagesize" that will give you all required information on
any system. (http://php.net/manual/en/function.getimagesize.php)

2. In current version you are checking mime type regarding cache file
exists or not. If cache file exists there is no need for this check, just
send the file or send 304. 

3. There should be a feature for creating proportional images based on
width or on height. I have created for my self this feature, I've
introduced new $zoom_crop value ("2") and put this peace of code:

if ($zoom_crop == 2) { 
    $ratio = $width/$height; 
    $new_height = $new_width / $ratio; 
}

above this line:

$canvas = imagecreatetruecolor( $new_width, $new_height ); 

Original issue reported on code.google.com by mirk...@gmail.com on 14 May 2010 at 11:31

GoogleCodeExporter commented 9 years ago
You're 1st point is totally right, a patch is attached :
if GD isn't there its pointless to use TimThumb

Moreover the if(!valid_src_mime_type($mime_type)) is (almost) never reached.
The file extension is not a good criterion to take into account.

About the second point, I think that it less costly to check the mime-type than 
computing the md5sum. But I agree that is should not happen.

About the third : other are related to this subject.

Original comment by raphael....@gmail.com on 1 Jul 2010 at 3:20

Attachments:

GoogleCodeExporter commented 9 years ago
/thanks for the suggestions. I've implemented the changes. Hopefully this will 
be just as robust as the old version :)

Original comment by BinaryMoon on 25 Sep 2010 at 10:16