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