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