/ Published in: PHP
                    
                                        
Creating thumbnails of the images is required many a times, this code will be useful to know about the logic of thumbnail generation.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
/**********************
*@filename - path to the image
*@tmpname - temporary path to thumbnail
*@xmax - max width
*@ymax - max height
*/
function resize_image($filename, $tmpname, $xmax, $ymax)
{
if($ext == "jpg" || $ext == "jpeg")
elseif($ext == "png")
elseif($ext == "gif")
if($x <= $xmax && $y <= $ymax)
return $im;
if($x >= $y) {
$newx = $xmax;
$newy = $newx * $y / $x;
}
else {
$newy = $ymax;
$newx = $x / $y * $newy;
}
return $im2;
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                