1--TEST-- 2imagecopyresampled() 3--SKIPIF-- 4<?php 5 if (!function_exists('imagecopyresampled')) die('skip imagecopyresampled() not available'); 6?> 7--FILE-- 8<?php 9 10echo "Simple test of imagecopyresampled() function\n"; 11 12$dest_lge = dirname(realpath(__FILE__)) . '/imagelarge.png'; 13$dest_sml = dirname(realpath(__FILE__)) . '/imagesmall.png'; 14 15// create a blank image 16$image_lge = imagecreatetruecolor(400, 300); 17 18// set the background color to black 19$bg = imagecolorallocate($image_lge, 0, 0, 0); 20 21// fill polygon with blue 22$col_ellipse = imagecolorallocate($image_lge, 0, 255, 0); 23 24// draw the eclipse 25imagefilledellipse($image_lge, 200, 150, 300, 200, $col_ellipse); 26 27// output the picture to a file 28imagepng($image_lge, $dest_lge); 29 30// Get new dimensions 31$percent = 0.5; // new image 50% of original 32list($width, $height) = getimagesize($dest_lge); 33echo "Size of original: width=". $width . " height=" . $height . "\n"; 34 35$new_width = $width * $percent; 36$new_height = $height * $percent; 37 38// Resample 39$image_sml = imagecreatetruecolor($new_width, $new_height); 40imagecopyresampled($image_sml, $image_lge, 0, 0, 0, 0, $new_width, $new_height, $width, $height); 41 42imagepng($image_sml, $dest_sml); 43 44list($width, $height) = getimagesize($dest_sml); 45echo "Size of copy: width=". $width . " height=" . $height . "\n"; 46 47imagedestroy($image_lge); 48imagedestroy($image_sml); 49 50 51echo "Done\n"; 52?> 53--CLEAN-- 54<?php 55 $dest_lge = dirname(realpath(__FILE__)) . '/imagelarge.png'; 56 $dest_sml = dirname(realpath(__FILE__)) . '/imagesmall.png'; 57 @unlink($dest_lge); 58 @unlink($dest_sml); 59?> 60--EXPECT-- 61Simple test of imagecopyresampled() function 62Size of original: width=400 height=300 63Size of copy: width=200 height=150 64Done 65