/ Published in: PHP
Create Image Thumbnail Quickly using PHP by simply passing the 4 arguments 1. the path to original image directory 2. the path to thumbnail directory 3. name of the file 4. width of the Thumbnail to be set Height it will apply based on width to maintain the resolution Supports jpg, gif and png files.
Expand |
Embed | Plain Text
function createThumbnail($path_to_image_directory, $path_to_thumbs_directory, $filename, $final_width_of_image) { $im = imagecreatefromjpeg($path_to_image_directory . $filename); $im = imagecreatefromgif($path_to_image_directory . $filename); $im = imagecreatefrompng($path_to_image_directory . $filename); } $ox = imagesx($im); $oy = imagesy($im); $nx = $final_width_of_image; $nm = imagecreatetruecolor($nx, $ny); imagecopyresized($nm, $im, 0,0,0,0,$nx,$ny,$ox,$oy); imagejpeg($nm, $path_to_thumbs_directory . $filename); }
You need to login to post a comment.
