This is a discussion on Re: Create Thumbnail within the alt.comp.lang.php forums, part of the PHP Programming Forums category; If you can use GD2 library use this function function create_resampled_image($max_height, $max_width, $image_quality, $image, $newimage){ $src_img = imagecreatefromjpeg($image); $orig_x = ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
If you can use GD2 library use this function
function create_resampled_image($max_height, $max_width, $image_quality, $image, $newimage){ $src_img = imagecreatefromjpeg($image); $orig_x = imagesx($src_img); $orig_y = imagesy($src_img); $new_y = $max_height; $new_x = $orig_x/($orig_y/$max_height); if ($new_x > $max_width) { $new_x = $max_width; $new_y = $orig_y/($orig_x/$max_width); } $dst_img = imagecreatetruecolor($new_x,$new_y); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $new_x, $new_y, $orig_x, $orig_y); imagejpeg($dst_img, $newimage, $image_quality); imagedestroy($src_img); imagedestroy($dst_img); } |
![]() |
| Thread Tools | |
| Display Modes | |
|
|