GMgKe586q6suSQnyqZLlGCooeWM

Pages

Search

Friday, March 11, 2011

PHP - Resizing Image

<?php
// File and new size
$filename = 'lamp.png';
$percent = 5.5;

// Content type
header('Content-type: image/png');

// Get new sizes
list($width, $height) = getimagesize($filename);
$newwidth = $width * $percent;
$newheight = $height * $percent;

// Load
$thumb = imagecreatetruecolor($newwidth, $newheight);
$source = imagecreatefrompng($filename);

// Resize
imagecopyresized($thumb, $source, 100, 100, 10, 10, $newwidth, $newheight, $width, $height);

// Output
imagepng($thumb);
imagedestroy($thumb);
?>

Share/Bookmark

No comments:

Post a Comment