How Create Thumbnail Image in PHP

How Create Thumbnail Image in PHP

How Create Thumbnail Image in PHP

Image GD

Image GD is a built in extension in php which is used to manipulate on the images in php. It can be used to create various small applications like captcha,create thumbnail, watermark etc.

Today we will learn how to create thumbnail image with php

function resizeandcopy($source,$dest,$size){
        $n_width=$size;
        $n_height=$size;
        $new_img = imagecreatefromjpeg($source);
        $width = imagesx($new_img);
        $height = imagesy($new_img);
        $aspect = $width/$height ;
    if($width > $height){
        $n_height = $n_width * (1/$aspect);
        }
    else{
        $n_width = $n_height * $aspect ;
        }
    $mythumb = imagecreatetruecolor($n_width,$n_height);
    imagecopyresized($mythumb,$new_img,0,0,0,0,$n_width,$n_height,$width,$height);
    imagejpeg($mythumb,$dest);
}

 

No Review

Post a Review

Thank you for contacting us !

Our Team will get in touch with you soon or call 8097057778 now to get answer for all your queries !

Like Our Facebook page to be up to date in industry !

wp4.5
Close