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