/ Published in: PHP
makes a resized duplicate of an image
Expand |
Embed | Plain Text
example: $imgId = $_FILES['article_image']['name']; //make thumbnail $this->ImageManager->makeImage(WWW_ROOT.'/img/articleImages/'.$imgId, WWW_ROOT.'/img/articleThumbs/'.$imgId, 85, 110); <?php class ImageManagerComponent extends Object { var $controller; function makeImage($input, $output, $max_width, $max_height) { $im = imagecreatefromjpeg($input); $orig_height = imagesy($im); $orig_width = imagesx($im); $ratio = ($orig_height>$orig_width) ? $max_width/$orig_width : $max_height/$orig_height; $new_width = $orig_width * $ratio; $new_height = $orig_height * $ratio; $new_im = imagecreatetruecolor($new_width,$new_height); imagecopyresampled($new_im,$im,0,0,0,0,$new_width,$new_height,$orig_width,$orig_height); imagejpeg($new_im); } function delete($fileName) { { return true; } else { return false; } } } ?>
You need to login to post a comment.
