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