Пример 1. Resizing an image
- This example will display the image at half size.
<?php // File and new size $filename = 'test.jpg'; $percent = 0.5;
// Content type header('Content-type: image/jpeg');
// Get new sizes list($width, $height) = getimagesize($filename); $newwidth = $width * $percent; $newheight = $height * $percent;
// Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($filename);
// Resize imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
// Output imagejpeg($thumb); ?>
|
- The image will be output at half size, though better quality could be obtained using imagecopyresampled().
|