/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function createThumb($width,$height,$quality,$filename,$newfilename){ //@author: zemin 1 => 'gif', 2 => 'jpeg', 3 => 'png' ); if (!$types[$info[2]]) return false; $ratio_orig = $info[0]/$info[1]; if ($width/$height > $ratio_orig) { $width = $height*$ratio_orig; } else { $height = $width/$ratio_orig; } $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefrom'.$types[$info[2]].'($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $info[0], $info[1]); $result = image'.$types[$info[2]].'($image_p, $newfilename, $quality); '); return $result; } ?>