diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2016-09-11 19:30:55 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2016-09-11 19:30:55 +0200 |
commit | 6ef987e012b505397ccc28d9014f14f762cbb07b (patch) | |
tree | 404c625381e73841371a85ad5e83e547bb50c481 | |
parent | 38455293f740e0444d16a247dc06db8d8ca18581 (diff) | |
download | php-git-6ef987e012b505397ccc28d9014f14f762cbb07b.tar.gz |
Split test for bundled vs. external libgd
The behavior of imagecropauto($im, IMG_CROP_DEFAULT) is rather different
for the bundled and an external libgd, see
<https://github.com/libgd/libgd/issues/298>.
Therefore we split the test for now.
-rw-r--r-- | ext/gd/tests/imagecrop_auto-ext.phpt | 85 | ||||
-rw-r--r-- | ext/gd/tests/imagecrop_auto.phpt | 1 |
2 files changed, 86 insertions, 0 deletions
diff --git a/ext/gd/tests/imagecrop_auto-ext.phpt b/ext/gd/tests/imagecrop_auto-ext.phpt new file mode 100644 index 0000000000..60291a69c0 --- /dev/null +++ b/ext/gd/tests/imagecrop_auto-ext.phpt @@ -0,0 +1,85 @@ +--TEST--
+Testing imagecropauto()
+--SKIPIF--
+<?php
+if ( ! extension_loaded('gd') || !function_exists('imagecrop')) die( 'skip GD imagecropauto not present; skipping test' );
+if (GD_BUNDLED) die('skip requires external libgd');
+?>
+--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)
diff --git a/ext/gd/tests/imagecrop_auto.phpt b/ext/gd/tests/imagecrop_auto.phpt index 1c1929d8e8..8a0f79d324 100644 --- a/ext/gd/tests/imagecrop_auto.phpt +++ b/ext/gd/tests/imagecrop_auto.phpt @@ -3,6 +3,7 @@ Testing imagecropauto() --SKIPIF--
<?php
if ( ! extension_loaded('gd') || !function_exists('imagecrop')) die( 'skip GD imagecropauto not present; skipping test' );
+if (!GD_BUNDLED) die('skip requires bundled libgd');
?>
--FILE--
<?php
|