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