/ Published in: PHP
If the optional parameter $crop is set to TRUE the image will be zoomed and cropped to specific size ($newsize). Else, the image will be resized to size, keeping aspect ratio and using $newsize as max size.
Expand |
Embed | Plain Text
function image_resize($input_file, $output_file, $new_size=75, $crop=true) { return false; } } $original = @imagecreatefromjpeg($input_file); } $original = @imagecreatefromgif($input_file); } $original = @imagecreatefrompng($input_file); } else { return false; } if ($original) { } else { return false; } if($crop == true) { } else { } if($crop == true) { } else { $ofx = $ofy = 0; } if($crop == true) { $small = imagecreatetruecolor($new_size, $new_size); } else { $small = imagecreatetruecolor($smallwidth, $smallheight); } } else { if($crop == true) { $small = imagecreate($new_size, $new_size); } else { $small = imagecreate($smallwidth, $smallheight); } } imagecopyresampled($small, $original, $ofx, $ofy, 0, 0, $smallwidth, $smallheight, $width, $height); } else { imagecopyresized($small, $original, $ofx, $ofy, 0, 0, $smallwidth, $smallheight, $width, $height); } if(imagejpeg($small, $output_file)) { return true; } } else { return false; } } }
You need to login to post a comment.
