xref: /PHP-7.3/ext/gd/tests/bug79676.phpt (revision 86e1f0ea)
1--TEST--
2Bug #79676 (imagescale adds black border with IMG_BICUBIC)
3--SKIPIF--
4<?php
5if (!extension_loaded('gd')) die('skip gd extension not available');
6?>
7--FILE--
8<?php
9function test($image, $desc)
10{
11    echo "$desc - Test Result: ",
12        (imagecolorat($image, imagesx($image) - 1 , imagesy($image) - 1) != 0x000000 ? 'pass' : 'fail'),
13        PHP_EOL;
14}
15
16$size = 32;
17$src = imagecreatetruecolor($size, $size);
18imagefilledrectangle($src, 0, 0, $size - 1 , $size - 1, 0xff00ff);
19
20test($src, 'No scaling');
21test(imagescale($src, $size * 2, $size * 2), 'Scale 200%, default mode');
22test(imagescale($src, $size / 2, $size / 2), 'Scale 50%, default mode');
23test(imagescale($src, $size * 2, $size * 2, IMG_BICUBIC), 'Scale 200%, IMG_BICUBIC mode');
24test(imagescale($src, $size / 2, $size / 2, IMG_BICUBIC), 'Scale 50%, IMG_BICUBIC mode');
25?>
26--EXPECT--
27No scaling - Test Result: pass
28Scale 200%, default mode - Test Result: pass
29Scale 50%, default mode - Test Result: pass
30Scale 200%, IMG_BICUBIC mode - Test Result: pass
31Scale 50%, IMG_BICUBIC mode - Test Result: pass
32