Skip to content

Commit 2024ff3

Browse files
committed
- add test for imagecropauto
1 parent 0a55c4b commit 2024ff3

File tree

2 files changed

+83
-0
lines changed

2 files changed

+83
-0
lines changed

UPGRADING

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ PHP 5.5 UPGRADE NOTES
177177
- GD
178178
- imageflip
179179
- imagecrop
180+
- imagecropauto
180181

181182
- Hash:
182183
- hash_pbkdf2()

ext/gd/tests/imagecrop_auto.phpt

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
--TEST--
2+
Testing imagecropauto()
3+
--SKIPIF--
4+
<?php
5+
if ( ! extension_loaded('gd') || !function_exists('imagecrop')) die( 'skip GD imagecropauto not present; skipping test' );
6+
?>
7+
--FILE--
8+
<?php
9+
10+
echo "TC IMG_CROP_DEFAULT\n";
11+
$im = imagecreatetruecolor(99, 99);
12+
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
13+
$im_crop = imagecropauto($im, IMG_CROP_DEFAULT);
14+
var_dump(imagesx($im_crop));
15+
var_dump(imagesy($im_crop));
16+
17+
echo "Palette IMG_CROP_DEFAULT\n";
18+
$im = imagecreate(99, 99);
19+
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
20+
$im_crop = imagecropauto($im, IMG_CROP_DEFAULT);
21+
var_dump(imagesx($im_crop));
22+
var_dump(imagesy($im_crop));
23+
24+
echo "TC IMG_CROP_SIDES\n";
25+
$im = imagecreatetruecolor(99, 99);
26+
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
27+
$im_crop = imagecropauto($im, IMG_CROP_SIDES);
28+
var_dump(imagesx($im_crop));
29+
var_dump(imagesy($im_crop));
30+
31+
echo "Palette IMG_CROP_SIDES\n";
32+
$im = imagecreate(99, 99);
33+
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
34+
$im_crop = imagecropauto($im, IMG_CROP_SIDES);
35+
var_dump(imagesx($im_crop));
36+
var_dump(imagesy($im_crop));
37+
38+
echo "TC IMG_CROP_BLACK\n";
39+
$im = imagecreatetruecolor(50, 50);
40+
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
41+
$im_crop = imagecropauto($im, IMG_CROP_BLACK);
42+
var_dump(imagesx($im_crop));
43+
var_dump(imagesy($im_crop));
44+
45+
echo "Palette IMG_CROP_BLACK\n";
46+
$im = imagecreate(50, 50);
47+
$bgd = imagecolorallocate($im, 0, 0, 0);
48+
$b = imagecolorallocate($im, 0, 0, 255);
49+
imagefilledrectangle($im, 20, 20, 30, 30, 0xff);
50+
$im_crop = imagecropauto($im, IMG_CROP_BLACK);
51+
var_dump(imagesx($im_crop));
52+
var_dump(imagesy($im_crop));
53+
54+
echo "IMG_CROP_THRESHOLD\n";
55+
$im = imagecreatefrompng("logo_noise.png");
56+
$im_crop = imagecropauto($im, IMG_CROP_THRESHOLD, 0.1, 0x0);
57+
imagepng($im_crop, __DIR__ . "/crop_threshold.png");
58+
var_dump(imagesx($im_crop));
59+
var_dump(imagesy($im_crop));
60+
?>
61+
--EXPECT--
62+
TC IMG_CROP_DEFAULT
63+
int(11)
64+
int(11)
65+
Palette IMG_CROP_DEFAULT
66+
int(11)
67+
int(11)
68+
TC IMG_CROP_SIDES
69+
int(11)
70+
int(11)
71+
Palette IMG_CROP_SIDES
72+
int(11)
73+
int(11)
74+
TC IMG_CROP_BLACK
75+
int(11)
76+
int(11)
77+
Palette IMG_CROP_BLACK
78+
int(11)
79+
int(11)
80+
IMG_CROP_THRESHOLD
81+
int(240)
82+
int(134)

0 commit comments

Comments
 (0)