web 2.0

How to use PHP & Resize image

How to use PHP & Resize image The guideline/example scripts how to using PHP and GD , Resize image

ShotDev Focus:
- PHP & GD (Resize image)

Example

php_resize.php


<?
$images = "mygirl.jpg";
$new_images = "MyResize/mygirl.jpg";
$width=200; //*** Fix Width & Heigh (Auto calculate) ***//
$size=GetimageSize($images);
$height=round($width*$size[1]/$size[0]);
$images_orig = ImageCreateFromJPEG($images);
$photoX = ImagesX($images_orig);
$photoY = ImagesY($images_orig);
$images_fin = ImageCreateTrueColor($width, $height);
ImageCopyResampled($images_fin, $images_orig, 0, 0, 0, 0, $width+1, $height+1, $photoX, $photoY);
ImageJPEG($images_fin,$new_images);
ImageDestroy($images_orig);
ImageDestroy($images_fin);
?>
<b>Original Size</b><br>
<img src="<?=$images;?>">
<hr>
<b>New Resize</b><br>
<img src="<?=$new_images;?>">

Create a php file and save to path root-path/myphp/

Run
http://localhost/myphp/php_resize.php

Screenshot

PHP & Resize image

.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.