mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
- Three of our gd tests could be skipped with a message about requiring
bundled GD, but those tests don't actually require bundled GD. We
update the messages to mention the specific functions that are
required.
- add SKIPIF stanzas for missing PNG support
The bundled libgd always has PNG support, but an external one may not.
- imagerotate() is always available
Following 59ec80c5, the imagerotate() function is always available. We
may therefore remove its function_exists() checks without harm.
close GH-17894
90 lines
2.2 KiB
PHP
90 lines
2.2 KiB
PHP
--TEST--
|
|
Testing imagecropauto()
|
|
--EXTENSIONS--
|
|
gd
|
|
--SKIPIF--
|
|
<?php
|
|
if (!function_exists('imagecrop')) die( 'skip GD imagecropauto not present; skipping test' );
|
|
if (!(imagetypes() & IMG_PNG)) {
|
|
die("skip No PNG support");
|
|
}
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
|
|
echo "TC IMG_CROP_DEFAULT\n";
|
|
$im = imagecreatetruecolor(99, 99);
|
|
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
|
|
$im_crop = imagecropauto($im, IMG_CROP_DEFAULT);
|
|
var_dump(imagesx($im_crop));
|
|
var_dump(imagesy($im_crop));
|
|
|
|
echo "Palette IMG_CROP_DEFAULT\n";
|
|
$im = imagecreate(99, 99);
|
|
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
|
|
$im_crop = imagecropauto($im, IMG_CROP_DEFAULT);
|
|
var_dump(imagesx($im_crop));
|
|
var_dump(imagesy($im_crop));
|
|
|
|
echo "TC IMG_CROP_SIDES\n";
|
|
$im = imagecreatetruecolor(99, 99);
|
|
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
|
|
$im_crop = imagecropauto($im, IMG_CROP_SIDES);
|
|
var_dump(imagesx($im_crop));
|
|
var_dump(imagesy($im_crop));
|
|
|
|
echo "Palette IMG_CROP_SIDES\n";
|
|
$im = imagecreate(99, 99);
|
|
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
|
|
$im_crop = imagecropauto($im, IMG_CROP_SIDES);
|
|
var_dump(imagesx($im_crop));
|
|
var_dump(imagesy($im_crop));
|
|
|
|
echo "TC IMG_CROP_BLACK\n";
|
|
$im = imagecreatetruecolor(50, 50);
|
|
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
|
|
$im_crop = imagecropauto($im, IMG_CROP_BLACK);
|
|
var_dump(imagesx($im_crop));
|
|
var_dump(imagesy($im_crop));
|
|
|
|
echo "Palette IMG_CROP_BLACK\n";
|
|
$im = imagecreate(50, 50);
|
|
$bgd = imagecolorallocate($im, 0, 0, 0);
|
|
$b = imagecolorallocate($im, 0, 0, 255);
|
|
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
|
|
$im_crop = imagecropauto($im, IMG_CROP_BLACK);
|
|
var_dump(imagesx($im_crop));
|
|
var_dump(imagesy($im_crop));
|
|
|
|
echo "IMG_CROP_THRESHOLD\n";
|
|
$im = imagecreatefrompng(__DIR__ . "/logo_noise.png");
|
|
$im_crop = imagecropauto($im, IMG_CROP_THRESHOLD, 0.1, 0x0);
|
|
imagepng($im_crop, __DIR__ . "/crop_threshold.png");
|
|
var_dump(imagesx($im_crop));
|
|
var_dump(imagesy($im_crop));
|
|
|
|
@unlink(__DIR__ . "/crop_threshold.png");
|
|
?>
|
|
--EXPECT--
|
|
TC IMG_CROP_DEFAULT
|
|
int(99)
|
|
int(99)
|
|
Palette IMG_CROP_DEFAULT
|
|
int(99)
|
|
int(99)
|
|
TC IMG_CROP_SIDES
|
|
int(11)
|
|
int(11)
|
|
Palette IMG_CROP_SIDES
|
|
int(11)
|
|
int(11)
|
|
TC IMG_CROP_BLACK
|
|
int(11)
|
|
int(11)
|
|
Palette IMG_CROP_BLACK
|
|
int(11)
|
|
int(11)
|
|
IMG_CROP_THRESHOLD
|
|
int(240)
|
|
int(134)
|