diff options
Diffstat (limited to 'ext/gd/tests')
275 files changed, 9838 insertions, 0 deletions
diff --git a/ext/gd/tests/001.phpt b/ext/gd/tests/001.phpt new file mode 100644 index 0000000..b0ac2a3 --- /dev/null +++ b/ext/gd/tests/001.phpt @@ -0,0 +1,25 @@ +--TEST-- +imagecreatefrompng() and empty/missing file +--SKIPIF-- +<?php if (!function_exists("imagecreatefrompng")) print "skip"; ?> +--FILE-- +<?php + +$file = dirname(__FILE__)."/001.test"; +@unlink($file); + +var_dump(imagecreatefrompng($file)); +touch($file); +var_dump(imagecreatefrompng($file)); + +@unlink($file); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: imagecreatefrompng(%s001.test): failed to open stream: No such file or directory in %s on line %d +bool(false) + +Warning: imagecreatefrompng(): '%s001.test' is not a valid PNG file in %s on line %d +bool(false) +Done diff --git a/ext/gd/tests/Tuffy.ttf b/ext/gd/tests/Tuffy.ttf Binary files differnew file mode 100755 index 0000000..8ea6470 --- /dev/null +++ b/ext/gd/tests/Tuffy.ttf diff --git a/ext/gd/tests/bug19366.phpt b/ext/gd/tests/bug19366.phpt new file mode 100644 index 0000000..2832f72 --- /dev/null +++ b/ext/gd/tests/bug19366.phpt @@ -0,0 +1,52 @@ +--TEST-- +Bug #19366 (gdimagefill() function crashes (fixed in bundled libgd)) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +echo "Alive: create image\n"; +$width = 50; +$height = 100; +$ImHandle = imagecreate($width,$height); + +echo "Alive: Define colors\n"; +$MyBlue = imagecolorAllocate($ImHandle, 0, 0, 255); +$MyRed = imagecolorAllocate($ImHandle, 255, 0, 0); +$MyWhite = imagecolorAllocate($ImHandle, 255, 255, 255); +$MyBlack = imagecolorAllocate($ImHandle, 0, 0, 0); + +echo "Alive: Draw\n"; +ImageFill($ImHandle,0,0,$MyBlack); +ImageLine($ImHandle,20,20,180,20,$MyWhite); +ImageLine($ImHandle,20,20,20,70,$MyBlue); +ImageLine($ImHandle,20,70,180,70,$MyRed); +ImageLine($ImHandle,180,20,180,45,$MyWhite); +ImageLine($ImHandle,180,70,180,45,$MyRed); +ImageLine($ImHandle,20,20,100,45,$MyBlue); +ImageLine($ImHandle,20,70,100,45,$MyBlue); +ImageLine($ImHandle,100,45,180,45,$MyRed); +ImageFill($ImHandle,21,45,$MyBlue); +ImageFill($ImHandle,100,69,$MyRed); +ImageFill($ImHandle,100,21,$MyWhite); + +echo "Alive: ImageString\n"; +ImageString($ImHandle,4,40,75,"Czech Republic",$MyWhite); + +echo "Alive: Send to browser\n"; +//Header("Content-type: image/PNG"); +//ImagePNG($ImHandle); + +echo "Alive: Free resources\n"; +imagedestroy($ImHandle); +echo "Alive: Done\n"; +?> +--EXPECT-- +Alive: create image +Alive: Define colors +Alive: Draw +Alive: ImageString +Alive: Send to browser +Alive: Free resources +Alive: Done diff --git a/ext/gd/tests/bug22544.phpt b/ext/gd/tests/bug22544.phpt new file mode 100644 index 0000000..4c8f763 --- /dev/null +++ b/ext/gd/tests/bug22544.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #22544 (TrueColor transparency in PNG images). +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available\n"); + } +?> +--FILE-- +<?php + $dest = dirname(realpath(__FILE__)) . '/bug22544.png'; + @unlink($dest); + $image = imageCreateTruecolor(640, 100); + $transparent = imageColorAllocate($image, 0, 0, 0); + $red = imageColorAllocate($image, 255, 50, 50); + imageColorTransparent($image, $transparent); + imageFilledRectangle($image, 0, 0, 640-1, 100-1, $transparent); + imagePng($image, $dest); + echo md5_file($dest) . "\n"; + @unlink($dest); +?> +--EXPECT-- +10a57d09a2c63fad87b85b38d6b258d6 diff --git a/ext/gd/tests/bug24155.phpt b/ext/gd/tests/bug24155.phpt new file mode 100644 index 0000000..43d34b7 --- /dev/null +++ b/ext/gd/tests/bug24155.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #24155 (gdImageRotate270 rotation problem). +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available\n"); + } + if (!function_exists("imagerotate")) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php + $dest = dirname(realpath(__FILE__)) . '/bug24155.png'; + @unlink($dest); + + $im = imagecreatetruecolor(30, 50); + imagefill($im, 0, 0, (16777215 - 255)); + $im = imagerotate($im, 270, 255); + imagepng($im, $dest); + + $im2 = imagecreatefrompng($dest); + + // Uniform fill + n x 90degrees rotation , the color value does not change + $col = imagecolorat($im2, 20, 20); + // 16777215 - 255 = 16776960 + echo "$col\n"; + + @unlink($dest); +?> +--EXPECT-- +16776960 diff --git a/ext/gd/tests/bug24594.phpt b/ext/gd/tests/bug24594.phpt new file mode 100644 index 0000000..f400649 --- /dev/null +++ b/ext/gd/tests/bug24594.phpt @@ -0,0 +1,82 @@ +--TEST-- +Bug #24594 (Filling an area using tiles). +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available\n"); + } +?> +--FILE-- +<?php + $tile = imagecreate(36,36); + $base = imagecreate(150,150); + $white = imagecolorallocate($tile,255,255,255); + $black = imagecolorallocate($tile,0,0,0); + $white = imagecolorallocate($base,255,255,255); + $black = imagecolorallocate($base,0,0,0); + + /* create the dots pattern */ + for ($x=0;$x<36;$x+=2) { + for ($y=0;$y<36;$y+=2) { + imagesetpixel($tile,$x,$y,$black); + } + } + + imagesettile($base,$tile); + imagerectangle($base, 9,9,139,139,$black); + imageline($base, 9,9,139,139,$black); + imagefill($base,11,12,IMG_COLOR_TILED); + + $res = imagecolorat($base,0,10)==$black?'1':'0'; + $res .= imagecolorat($base,0,20)==$black?'1':'0'; + $res .= imagecolorat($base,0,30)==$black?'1':'0'; + $res .= imagecolorat($base,0,40)==$black?'1':'0'; + $res .= imagecolorat($base,0,50)==$black?'1':'0'; + $res .= imagecolorat($base,0,60)==$black?'1':'0'; + + $res .= imagecolorat($base,11,12)==$white?'1':'0'; + $res .= imagecolorat($base,12,13)==$white?'1':'0'; + $res .= imagecolorat($base,13,14)==$white?'1':'0'; + $res .= imagecolorat($base,14,15)==$white?'1':'0'; + $res .= imagecolorat($base,15,16)==$white?'1':'0'; + $res .= imagecolorat($base,16,17)==$white?'1':'0'; + + $res .= imagecolorat($base,10,12)==$black?'1':'0'; + $res .= imagecolorat($base,11,13)==$black?'1':'0'; + $res .= imagecolorat($base,12,14)==$black?'1':'0'; + $res .= imagecolorat($base,13,15)==$black?'1':'0'; + $res .= imagecolorat($base,14,16)==$black?'1':'0'; + $res .= imagecolorat($base,15,17)==$black?'1':'0'; + echo "$res\n"; + + imagefilledrectangle($base,0,0,149,149,$white); + imagerectangle($base, 9,9,139,139,$black); + imageline($base, 9,9,139,139,$black); + imagefill($base,0,0,IMG_COLOR_TILED); + + $res = imagecolorat($base,0,10)==$black?'1':'0'; + $res .= imagecolorat($base,0,20)==$black?'1':'0'; + $res .= imagecolorat($base,0,30)==$black?'1':'0'; + $res .= imagecolorat($base,0,40)==$black?'1':'0'; + $res .= imagecolorat($base,0,50)==$black?'1':'0'; + $res .= imagecolorat($base,0,60)==$black?'1':'0'; + + $res .= imagecolorat($base,11,12)==$white?'1':'0'; + $res .= imagecolorat($base,12,13)==$white?'1':'0'; + $res .= imagecolorat($base,13,14)==$white?'1':'0'; + $res .= imagecolorat($base,14,15)==$white?'1':'0'; + $res .= imagecolorat($base,15,16)==$white?'1':'0'; + $res .= imagecolorat($base,16,17)==$white?'1':'0'; + + $res .= imagecolorat($base,0,16)==$black?'1':'0'; + $res .= imagecolorat($base,2,42)==$black?'1':'0'; + $res .= imagecolorat($base,4,44)==$black?'1':'0'; + $res .= imagecolorat($base,146,146)==$black?'1':'0'; + $res .= imagecolorat($base,148,146)==$black?'1':'0'; + $res .= imagecolorat($base,0,0)==$black?'1':'0'; + + echo "$res\n"; +?> +--EXPECT-- +000000111111101010 +111111111111111111 diff --git a/ext/gd/tests/bug27582_1.phpt b/ext/gd/tests/bug27582_1.phpt new file mode 100644 index 0000000..28db15a --- /dev/null +++ b/ext/gd/tests/bug27582_1.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #27582 (ImageFillToBorder() on alphablending image looses alpha on fill color) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +/* $id$ */ +$dest = dirname(realpath(__FILE__)) . '/bug27582.png'; +@unlink($dest); +$im = ImageCreateTrueColor(10, 10); +imagealphablending($im, true); +imagesavealpha($im, true); +$bordercolor=ImageColorAllocateAlpha($im, 0, 0, 0, 2); +$color = ImageColorAllocateAlpha($im, 0, 0, 0, 1); +ImageFillToBorder($im, 5, 5, $bordercolor, $color); +imagepng($im, $dest); + +$im2 = imagecreatefrompng($dest); +$col = imagecolorat($im2, 5, 5); +$color = imagecolorsforindex($im2, $col); +echo $color['alpha']; +@unlink($dest); +?> +--EXPECT-- +1 diff --git a/ext/gd/tests/bug28147.phpt b/ext/gd/tests/bug28147.phpt new file mode 100644 index 0000000..de5c902 --- /dev/null +++ b/ext/gd/tests/bug28147.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #28147 (Crash with anti-aliased line) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (!function_exists("imageantialias")) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php +// +// This script will generate a Seg Fault on Linux +// +$im = imagecreatetruecolor(300, 300); +$w = imagecolorallocate($im, 255, 255, 255); +$red = imagecolorallocate($im, 255, 0, 0); + +imagefilledrectangle($im,0,0,299,299,$w); + +imageantialias($im,true); +imageline($im, 299, 299, 0, 299, $red); + +imagedestroy($im); + +echo "Alive\n"; +?> +--EXPECT-- +Alive diff --git a/ext/gd/tests/bug36697.phpt b/ext/gd/tests/bug36697.phpt new file mode 100644 index 0000000..9335e5f --- /dev/null +++ b/ext/gd/tests/bug36697.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #36697 (TrueColor transparency with GIF palette output). +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available\n"); + } +?> +--FILE-- +<?php +$dest = dirname(__FILE__) . "/36697.gif"; + +$im = imagecreatetruecolor(192, 36); +$trans_color = imagecolorallocate($im, 255, 0, 0); +$color = imagecolorallocate($im, 255, 255, 255); +imagecolortransparent($im, $trans_color); +imagefilledrectangle($im, 0,0, 192,36, $trans_color); +$c = imagecolorat($im, 191,35); +imagegif($im, $dest); +imagedestroy($im); +$im = imagecreatefromgif($dest); +$c = imagecolorat($im, 191, 35); +$colors = imagecolorsforindex($im, $c); +echo $colors['red'] . ' ' . $colors['green'] . ' ' . $colors['blue']; +@unlink($dest); +?> +--EXPECT-- +255 0 0 diff --git a/ext/gd/tests/bug37346.gif b/ext/gd/tests/bug37346.gif new file mode 100644 index 0000000..76ce1e3 --- /dev/null +++ b/ext/gd/tests/bug37346.gif @@ -0,0 +1,4 @@ +GIF89a
+<
+
+¿´°É, ÎÒ¶¼Ëµ¹ýÂ˲»ÑÏÁË
\ No newline at end of file diff --git a/ext/gd/tests/bug37346.phpt b/ext/gd/tests/bug37346.phpt new file mode 100644 index 0000000..36d9c0a --- /dev/null +++ b/ext/gd/tests/bug37346.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #37346 (gdimagecreatefromgif, bad colormap) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$im = imagecreatefromgif(dirname(__FILE__) . '/bug37346.gif'); +?> +--EXPECTF-- +Warning: imagecreatefromgif(): '%sbug37346.gif' is not a valid GIF file in %sbug37346.php on line %d diff --git a/ext/gd/tests/bug37360.gif b/ext/gd/tests/bug37360.gif Binary files differnew file mode 100644 index 0000000..3f9e6c5 --- /dev/null +++ b/ext/gd/tests/bug37360.gif diff --git a/ext/gd/tests/bug37360.phpt b/ext/gd/tests/bug37360.phpt new file mode 100644 index 0000000..44bbd96 --- /dev/null +++ b/ext/gd/tests/bug37360.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #37360 (gdimagecreatefromgif, bad image sizes) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$im = imagecreatefromgif(dirname(__FILE__) . '/bug37360.gif'); +var_dump($im); +?> +--EXPECTF-- +Warning: imagecreatefromgif(): '%s' is not a valid GIF file in %s on line %d +bool(false) diff --git a/ext/gd/tests/bug38112.gif b/ext/gd/tests/bug38112.gif Binary files differnew file mode 100644 index 0000000..178d27e --- /dev/null +++ b/ext/gd/tests/bug38112.gif diff --git a/ext/gd/tests/bug38112.phpt b/ext/gd/tests/bug38112.phpt new file mode 100644 index 0000000..0e4b8af --- /dev/null +++ b/ext/gd/tests/bug38112.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #38112 (GIF Invalid Code size ). +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available\n"); + } +?> +--FILE-- +<?php +$im = imagecreatefromgif(dirname(__FILE__) . '/bug38112.gif'); +?> +--EXPECTF-- +Warning: imagecreatefromgif(): '%sbug38112.gif' is not a valid GIF file in %sbug38112.php on line %d diff --git a/ext/gd/tests/bug38179.phpt b/ext/gd/tests/bug38179.phpt new file mode 100644 index 0000000..34a6d58 --- /dev/null +++ b/ext/gd/tests/bug38179.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #38179 (imagecopy from a palette to a truecolor image loses alpha channel) +--SKIPIF-- +<?php + if (!function_exists('imagecopy')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$src = imagecreate(5,5); +$c0 = imagecolorallocate($src, 255,255,255); +$c1 = imagecolorallocatealpha($src, 255,0,0,70); + +imagealphablending($src, 0); +imagefill($src, 0,0, $c1); + +$dst_tc = imagecreatetruecolor(5,5); +imagealphablending($dst_tc, 0); + +imagecopy($dst_tc, $src, 0,0, 0,0, imagesx($src), imagesy($src)); + +$p1 = imagecolorat($dst_tc, 3,3); +printf("%X\n", $p1); + +imagedestroy($src); imagedestroy($dst_tc); +?> +--EXPECTF-- +46FF0000 + diff --git a/ext/gd/tests/bug38212.phpt b/ext/gd/tests/bug38212.phpt new file mode 100644 index 0000000..7548008 --- /dev/null +++ b/ext/gd/tests/bug38212.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #38212 (Seg Fault on invalid imagecreatefromgd2part() parameters) +--SKIPIF-- +<?php + if (!function_exists('imagecopy')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$file = dirname(__FILE__) . '/bug38212.gd2'; +$im1 = imagecreatetruecolor(10,100); +imagefill($im1, 0,0, 0xffffff); +imagegd2($im1, $file); +$im = imagecreatefromgd2part($file, 0,0, -25,10); +unlink($file); +?> +--EXPECTF-- + +Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d diff --git a/ext/gd/tests/bug39082.phpt b/ext/gd/tests/bug39082.phpt new file mode 100644 index 0000000..9bd6f5e --- /dev/null +++ b/ext/gd/tests/bug39082.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #39082 (Output image to stdout segfaults). +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available\n"); + } +?> +--FILE-- +<?php +$im = imagecreatetruecolor(1,1); +imagegif($im); +?> +--EXPECTF-- +GIF87a%s diff --git a/ext/gd/tests/bug39273.phpt b/ext/gd/tests/bug39273.phpt new file mode 100644 index 0000000..9867b74 --- /dev/null +++ b/ext/gd/tests/bug39273.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #37360 (gdimagecreatefromgif, bad image sizes) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$small = imagecreatetruecolor(10, 10); +$c1 = imagecolorallocatealpha($small, 255,0,0,50); +imagecolortransparent($small, 0); +imagealphablending($small, 0); +imagefilledrectangle($small, 0,0, 6,6, $c1); + +$width = 300; +$height = 300; +$srcw = imagesx($small); +$srch = imagesy($small); + +$img = imagecreatetruecolor($width, $height); + +imagecolortransparent($img, 0); +imagealphablending($img, false); +imagecopyresized($img, $small, 0,0, 0,0, $width, $height, $srcw, $srch); +imagesavealpha($img, 1); + +$c = imagecolorat($img, 0,0); +printf("%X", $c); +?> +--EXPECTF-- +32FF0000 diff --git a/ext/gd/tests/bug39286.phpt b/ext/gd/tests/bug39286.phpt new file mode 100644 index 0000000..9171fb7 --- /dev/null +++ b/ext/gd/tests/bug39286.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #39508 (imagefill crashes with small images 3 pixels or less) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$img =imagecreatefromgd2part("foo.png",0, 100, 0, 100); +?> +--EXPECTF-- + +Warning: imagecreatefromgd2part(): Zero width or height not allowed in %s on line %d diff --git a/ext/gd/tests/bug39366.phpt b/ext/gd/tests/bug39366.phpt new file mode 100644 index 0000000..f805645 --- /dev/null +++ b/ext/gd/tests/bug39366.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #39366 (imagerotate does not respect alpha with angles>45) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (!function_exists("imagerotate")) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php + +$im = imagecreatetruecolor(10,10); +imagealphablending($im, 0); +imagefilledrectangle($im, 0,0, 8,8, 0x32FF0000); +$rotate = imagerotate($im, 180, 0); +imagecolortransparent($rotate,0); +imagesavealpha($rotate, true); +$c = imagecolorat($rotate,5,5); +printf("%X\n", $c); +?> +--EXPECTF-- +32FF0000 diff --git a/ext/gd/tests/bug39508.phpt b/ext/gd/tests/bug39508.phpt new file mode 100644 index 0000000..791c59c --- /dev/null +++ b/ext/gd/tests/bug39508.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #39508 (imagefill crashes with small images 3 pixels or less) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$im = imagecreatetruecolor(3,1); +$bgcolor = imagecolorallocatealpha($im,255, 255, 0, 0); +imagefill($im,0,0,$bgcolor); +print_r(imagecolorat($im, 1,0)); +?> +--EXPECTF-- +16776960 diff --git a/ext/gd/tests/bug39780.phpt b/ext/gd/tests/bug39780.phpt new file mode 100644 index 0000000..964cf69 --- /dev/null +++ b/ext/gd/tests/bug39780.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #39780 (PNG image with CRC/data error raises a fatal error) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php + +$im = imagecreatefrompng(dirname(__FILE__) . '/bug39780.png'); +var_dump($im); +?> +--EXPECTF-- + +Warning: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncated data in %s on line %d + +Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition in %s on line %d + +Warning: imagecreatefrompng(): '%s' is not a valid PNG file in %s on line %d +bool(false) diff --git a/ext/gd/tests/bug39780.png b/ext/gd/tests/bug39780.png Binary files differnew file mode 100644 index 0000000..73a7d6a --- /dev/null +++ b/ext/gd/tests/bug39780.png diff --git a/ext/gd/tests/bug39780_extern.phpt b/ext/gd/tests/bug39780_extern.phpt new file mode 100644 index 0000000..79ed4f2 --- /dev/null +++ b/ext/gd/tests/bug39780_extern.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #39780 (PNG image with CRC/data error raises a fatal error) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (GD_BUNDLED) die("skip requires extern GD\n"); +?> +--FILE-- +<?php + +$im = imagecreatefrompng(dirname(__FILE__) . '/bug39780.png'); +var_dump($im); +?> +--EXPECTF-- +gd-png: fatal libpng error: Read Error: truncated data +gd-png error: setjmp returns error condition 2 +Warning: imagecreatefrompng(): '%sbug39780.png' is not a valid PNG file in /%s on line %d +bool(false)
\ No newline at end of file diff --git a/ext/gd/tests/bug40764.phpt b/ext/gd/tests/bug40764.phpt new file mode 100644 index 0000000..cbe262f --- /dev/null +++ b/ext/gd/tests/bug40764.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #40764 (line thickness not respected for horizontal and vertical lines) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$image=imagecreatetruecolor(400, 400); +$white = imagecolorallocate($image, 255, 255, 255); +$black = imagecolorallocate($image, 0, 0, 0); +$red = imagecolorallocate($image, 255, 0, 0); + +imagefill($image, 0, 0, $white); +imagesetthickness($image, 10); + +imageline($image, 200, 0, 200, 400, $black); +imageline($image, 0, 200, 400, 200, $black); +imageline($image, 0, 0, 392, 392, $black); + +imagesetthickness($image, 1); + +imageline($image, 200, 0, 200, 400, $red); +imageline($image, 0, 200, 400, 200, $red); +imageline($image, 0, 0, 392, 392, $red); +print_r(imagecolorat($image, 195, 0)); +print_r(imagecolorat($image, 0, 195)); + +?> +--EXPECT-- +00 diff --git a/ext/gd/tests/bug41442.phpt b/ext/gd/tests/bug41442.phpt new file mode 100644 index 0000000..78a61be --- /dev/null +++ b/ext/gd/tests/bug41442.phpt @@ -0,0 +1,37 @@ +--TEST-- +Bug #41442 (imagegd2() under output control) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + if (!function_exists("imagegd2")) { + die("skip GD2 support unavailable"); + } +?> +--FILE-- +<?php + +$str = file_get_contents(dirname(__FILE__).'/src.gd2'); +$res = imagecreatefromstring($str); + +/* string */ +ob_start(); +imagegd2($res); +$str2 = ob_get_clean(); +var_dump(imagecreatefromstring($str2)); + +/* file */ +$file = dirname(__FILE__)."/bug41442.gd2"; +imagegd2($res, $file); +$str2 = file_get_contents($file); +var_dump(imagecreatefromstring($str2)); + +@unlink($file); + +echo "Done\n"; +?> +--EXPECTF-- +resource(%d) of type (gd) +resource(%d) of type (gd) +Done diff --git a/ext/gd/tests/bug42434.phpt b/ext/gd/tests/bug42434.phpt new file mode 100644 index 0000000..bc0790e --- /dev/null +++ b/ext/gd/tests/bug42434.phpt @@ -0,0 +1,27 @@ +--TEST--
+Bug #42434 (ImageLine w/ antialias = 1px shorter)
+--SKIPIF--
+<?php
+if (!extension_loaded('gd')) {
+ die('skip gd extension not available');
+}
+if (!GD_BUNDLED) die("skip requires bundled GD library\n");
+?>
+--FILE--
+<?php
+$im = imagecreatetruecolor(10, 2);
+imagefilledrectangle($im, 0, 0, 10, 2, 0xFFFFFF);
+
+imageantialias($im, true);
+imageline($im, 0, 0, 10, 0, 0x000000);
+
+if (imagecolorat($im, 9, 0) == 0x000000) {
+ echo 'DONE';
+} else {
+ echo 'Bugged';
+}
+
+imagedestroy($im);
+?>
+--EXPECTF--
+DONE
\ No newline at end of file diff --git a/ext/gd/tests/bug43073.phpt b/ext/gd/tests/bug43073.phpt new file mode 100644 index 0000000..4f448f2 --- /dev/null +++ b/ext/gd/tests/bug43073.phpt @@ -0,0 +1,51 @@ +--TEST-- +Bug #43073 (TrueType bounding box is wrong for angle<>0) freetype < 2.4.10 +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available'); } + if(!function_exists('imagettftext')) die('skip imagettftext() not available'); + + include dirname(__FILE__) . '/func.inc'; + if(version_compare(get_freetype_version(), '2.4.10') >= 0) die('skip for freetype < 2.4.10'); +?> +--FILE-- +<?php +$cwd = dirname(__FILE__); +$font = "$cwd/Tuffy.ttf"; +$delta_t = 360.0 / 16; # Make 16 steps around +$g = imagecreate(800, 800); +$bgnd = imagecolorallocate($g, 255, 255, 255); +$black = imagecolorallocate($g, 0, 0, 0); +$x = 100; +$y = 0; +$cos_t = cos(deg2rad($delta_t)); +$sin_t = sin(deg2rad($delta_t)); +for ($angle = 0.0; $angle < 360.0; $angle += $delta_t) { + $bbox = imagettftext($g, 24, $angle, 400+$x, 400+$y, $black, $font, 'ABCDEF'); + $s = vsprintf("(%d, %d), (%d, %d), (%d, %d), (%d, %d)\n", $bbox); + echo $s; + $temp = $cos_t * $x + $sin_t * $y; + $y = $cos_t * $y - $sin_t * $x; + $x = $temp; +} +imagepng($g, "$cwd/bug43073.png"); +?> +--CLEAN-- +<?php @unlink(dirname(__FILE__) . '/bug43073.png'); ?> +--EXPECTF-- +(500, 402), (610, 402), (610, 376), (500, 376) +(492, 363), (591, 322), (580, 295), (480, 336) +(470, 331), (548, 254), (527, 233), (449, 310) +(439, 309), (483, 202), (461, 193), (416, 299) +(401, 300), (401, 183), (381, 183), (381, 300) +(362, 307), (316, 195), (291, 205), (337, 318) +(330, 329), (246, 244), (224, 265), (308, 350) +(308, 360), (202, 316), (190, 344), (296, 388) +(300, 399), (186, 399), (186, 425), (300, 425) +(306, 437), (195, 483), (206, 510), (318, 464) +(328, 469), (240, 557), (260, 578), (349, 491) +(359, 491), (312, 607), (334, 616), (382, 501) +(398, 500), (398, 618), (418, 618), (418, 500) +(436, 493), (483, 607), (507, 597), (461, 482) +(468, 471), (555, 558), (577, 538), (490, 450) +(490, 440), (600, 485), (611, 457), (502, 412) diff --git a/ext/gd/tests/bug43073_1.phpt b/ext/gd/tests/bug43073_1.phpt new file mode 100644 index 0000000..b69067d --- /dev/null +++ b/ext/gd/tests/bug43073_1.phpt @@ -0,0 +1,51 @@ +--TEST-- +Bug #43073 (TrueType bounding box is wrong for angle<>0) freetype >= 2.4.10 +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available'); } + if(!function_exists('imagettftext')) die('skip imagettftext() not available'); + + include dirname(__FILE__) . '/func.inc'; + if(version_compare(get_freetype_version(), '2.4.10') == -1) die('skip for freetype >= 2.4.10'); +?> +--FILE-- +<?php +$cwd = dirname(__FILE__); +$font = "$cwd/Tuffy.ttf"; +$delta_t = 360.0 / 16; # Make 16 steps around +$g = imagecreate(800, 800); +$bgnd = imagecolorallocate($g, 255, 255, 255); +$black = imagecolorallocate($g, 0, 0, 0); +$x = 100; +$y = 0; +$cos_t = cos(deg2rad($delta_t)); +$sin_t = sin(deg2rad($delta_t)); +for ($angle = 0.0; $angle < 360.0; $angle += $delta_t) { + $bbox = imagettftext($g, 24, $angle, 400+$x, 400+$y, $black, $font, 'ABCDEF'); + $s = vsprintf("(%d, %d), (%d, %d), (%d, %d), (%d, %d)\n", $bbox); + echo $s; + $temp = $cos_t * $x + $sin_t * $y; + $y = $cos_t * $y - $sin_t * $x; + $x = $temp; +} +imagepng($g, "$cwd/bug43073.png"); +?> +--CLEAN-- +<?php @unlink(dirname(__FILE__) . '/bug43073.png'); ?> +--EXPECTF-- +(500, 400), (610, 400), (610, 376), (500, 376) +(492, 363), (591, 322), (580, 295), (480, 336) +(470, 331), (548, 254), (527, 233), (449, 310) +(439, 309), (483, 202), (461, 193), (416, 299) +(400, 300), (400, 183), (380, 183), (380, 300) +(362, 307), (316, 195), (291, 205), (337, 318) +(330, 329), (246, 244), (224, 265), (308, 350) +(308, 360), (202, 316), (190, 344), (296, 388) +(300, 400), (187, 400), (187, 425), (300, 425) +(306, 437), (195, 483), (206, 510), (318, 464) +(328, 469), (240, 557), (260, 578), (349, 491) +(359, 491), (312, 607), (334, 616), (382, 501) +(400, 500), (400, 618), (419, 618), (419, 500) +(436, 493), (483, 607), (507, 597), (461, 482) +(468, 471), (555, 558), (577, 538), (490, 450) +(490, 440), (600, 485), (611, 457), (502, 412) diff --git a/ext/gd/tests/bug43121.gif b/ext/gd/tests/bug43121.gif Binary files differnew file mode 100644 index 0000000..44caffc --- /dev/null +++ b/ext/gd/tests/bug43121.gif diff --git a/ext/gd/tests/bug43121.phpt b/ext/gd/tests/bug43121.phpt new file mode 100644 index 0000000..ce2d1d6 --- /dev/null +++ b/ext/gd/tests/bug43121.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #43121 (gdImageFill with IMG_COLOR_TILED crashes httpd) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$im = ImageCreate( 200, 100 ); +$black = ImageColorAllocate( $im, 0, 0, 0 ); + +$im_tile = ImageCreateFromGif(dirname(__FILE__) . "/bug43121.gif" ); +ImageSetTile( $im, $im_tile ); +ImageFill( $im, 0, 0, IMG_COLOR_TILED ); + +ImageDestroy( $im ); + +print "OK"; +?> +--EXPECTF-- +OK diff --git a/ext/gd/tests/bug44849.phpt b/ext/gd/tests/bug44849.phpt new file mode 100644 index 0000000..a6d162c --- /dev/null +++ b/ext/gd/tests/bug44849.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #44849 (imagecolorclosesthwb is not available on Windows) +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available'); } +?> +--FILE-- +<?php + var_dump(function_exists('imagecolorclosesthwb')); +?> +--EXPECTF-- +bool(true) diff --git a/ext/gd/tests/bug45799.phpt b/ext/gd/tests/bug45799.phpt new file mode 100644 index 0000000..a28f940 --- /dev/null +++ b/ext/gd/tests/bug45799.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #45799 (imagepng() crashes on empty image). +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$img = imagecreate(500,500); +imagepng($img); +imagedestroy($img); +?> +--EXPECTF-- + +Warning: imagepng(): gd-png error: no colors in palette in %s on line %d diff --git a/ext/gd/tests/bug48555.phpt b/ext/gd/tests/bug48555.phpt new file mode 100644 index 0000000..d378aaf --- /dev/null +++ b/ext/gd/tests/bug48555.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #48555 (ImageFTBBox() differs from previous versions for texts with new lines) +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available'); } + if(!function_exists('imageftbbox')) die('skip imageftbbox() not available'); +?> +--FILE-- +<?php +$cwd = dirname(__FILE__); +$font = "$cwd/Tuffy.ttf"; +$box = ImageFTBBox(14, 0, $font, "Text without line-break"); +//echo 'Top without line-break: ' . $box[7] . "\n"; +$without_line_break = $box[7]; +$box = ImageFTBBox(14, 0, $font, "Text with\nline-break\none more"); +//echo 'Top with line-break: ' . $box[7] . "\n"; +$with_line_break = $box[7]; + +var_dump($without_line_break); +var_dump($with_line_break); +if ($with_line_break==$without_line_break) { + echo "with line break == without line break".PHP_EOL; +} else { + echo "with line break != without line break".PHP_EOL; +} + +?> +--EXPECTF-- +int(-%d) +int(-%d) +with line break == without line break diff --git a/ext/gd/tests/bug48732.phpt b/ext/gd/tests/bug48732.phpt new file mode 100644 index 0000000..f8cb5e2 --- /dev/null +++ b/ext/gd/tests/bug48732.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #48732 (TTF Bounding box wrong for letters below baseline) +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available'); } + if(!function_exists('imagefttext')) die('skip imagefttext() not available'); +?> +--FILE-- +<?php +$cwd = dirname(__FILE__); +$font = "$cwd/Tuffy.ttf"; +$g = imagecreate(100, 50); +$bgnd = imagecolorallocate($g, 255, 255, 255); +$black = imagecolorallocate($g, 0, 0, 0); +$bbox = imagettftext($g, 12, 0, 0, 20, $black, $font, "ABCEDFGHIJKLMN\nopqrstu\n"); +imagepng($g, "$cwd/bug48732.png"); +echo 'Left Bottom: (' . $bbox[0] . ', ' . $bbox[1] . ')'; +?> +--CLEAN-- +<?php @unlink(dirname(__FILE__) . '/bug48732.png'); ?> +--EXPECTF-- +Left Bottom: (0, 47) diff --git a/ext/gd/tests/bug48801.phpt b/ext/gd/tests/bug48801.phpt new file mode 100644 index 0000000..fd25541 --- /dev/null +++ b/ext/gd/tests/bug48801.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #48801 (Problem with imagettfbbox) freetype < 2.4.10 +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available'); } + if(!function_exists('imageftbbox')) die('skip imageftbbox() not available'); + + include dirname(__FILE__) . '/func.inc'; + if(version_compare(get_freetype_version(), '2.4.10') >= 0) die('skip for freetype < 2.4.10'); +?> +--FILE-- +<?php +$cwd = dirname(__FILE__); +$font = "$cwd/Tuffy.ttf"; +$bbox = imageftbbox(50, 0, $font, "image"); +echo '(' . $bbox[0] . ', ' . $bbox[1] . ")\n"; +echo '(' . $bbox[2] . ', ' . $bbox[3] . ")\n"; +echo '(' . $bbox[4] . ', ' . $bbox[5] . ")\n"; +echo '(' . $bbox[6] . ', ' . $bbox[7] . ")\n"; +?> +--EXPECTF-- +(-1, 15) +(155, 15) +(155, -48) +(-1, -48) diff --git a/ext/gd/tests/bug48801_1.phpt b/ext/gd/tests/bug48801_1.phpt new file mode 100644 index 0000000..11af80c --- /dev/null +++ b/ext/gd/tests/bug48801_1.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #48801 (Problem with imagettfbbox) freetype >= 2.4.10 +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available'); } + if(!function_exists('imageftbbox')) die('skip imageftbbox() not available'); + + include dirname(__FILE__) . '/func.inc'; + if(version_compare(get_freetype_version(), '2.4.10') == -1) die('skip for freetype >= 2.4.10'); +?> +--FILE-- +<?php +$cwd = dirname(__FILE__); +$font = "$cwd/Tuffy.ttf"; +$bbox = imageftbbox(50, 0, $font, "image"); +echo '(' . $bbox[0] . ', ' . $bbox[1] . ")\n"; +echo '(' . $bbox[2] . ', ' . $bbox[3] . ")\n"; +echo '(' . $bbox[4] . ', ' . $bbox[5] . ")\n"; +echo '(' . $bbox[6] . ', ' . $bbox[7] . ")\n"; +?> +--EXPECTF-- +(-1, 15) +(156, 15) +(156, -48) +(-1, -48) diff --git a/ext/gd/tests/bug49600.phpt b/ext/gd/tests/bug49600.phpt new file mode 100644 index 0000000..068f8f3 --- /dev/null +++ b/ext/gd/tests/bug49600.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #49600 (imageTTFText text shifted right) +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available'); } + if(!function_exists('imagettftext')) die('skip imagettftext() not available'); + if(!function_exists('imagettfbbox')) die('skip imagettfbbox() not available'); +?> +--FILE-- +<?php +$cwd = dirname(__FILE__); +$font = "$cwd/Tuffy.ttf"; +$image = imagecreatetruecolor(50, 50); +$color = imagecolorallocate($image, 255, 255, 255); +foreach (array("E", "I", "P", "g", "i", "q") as $c) +{ + $x = imagettftext($image, 32, 0, 0, 0, $color, $font, $c); + $y = imagettfbbox(32, 0, "$cwd/Tuffy.ttf", $c); + if ( abs($x[0] - $y[0]) > 1 + || abs($x[2] - $y[2]) > 1 + || abs($x[4] - $y[4]) > 1 + || abs($x[6] - $y[6]) > 1 ) { + echo "FAILED: \n"; + var_dump($x); + var_dump($y); + exit; + } +} +echo 'OK'; +?> +--EXPECTF-- +OK
\ No newline at end of file diff --git a/ext/gd/tests/bug51263.phpt b/ext/gd/tests/bug51263.phpt new file mode 100644 index 0000000..8e86f41 --- /dev/null +++ b/ext/gd/tests/bug51263.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #51263 (imagettftext and rotated text uses wrong baseline) +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available'); } + if(!function_exists('imagettftext')) die('skip imagettftext() not available'); +?> +--FILE-- +<?php +$cwd = dirname(__FILE__); +$ttf = "$cwd/Tuffy.ttf"; +$w = 23; +$h = 70; +$img = imagecreatetruecolor($w, $h); +$blk = imagecolorallocate($img, 0, 0, 0); +imagefilledrectangle($img, 0, 0, $w-1, $h-1, $blk); +$col = imagecolorallocate($img, 255, 255, 255); +imagettftext($img, 8, 90, 10, 60, $col, $ttf, "foo bar qux"); +$x = array(0, 1, 2, 3, 13); +for ($j=0; $j<30; $j++) { + foreach ($x as $i) { + $c = imagecolorat($img, $i, $j); + if ($c != 0) { + echo "KO: ($i, $j)\n"; + exit; + } + } +} +echo "OK\n"; +?> +--EXPECTF-- +OK diff --git a/ext/gd/tests/bug51671.phpt b/ext/gd/tests/bug51671.phpt new file mode 100644 index 0000000..5dd77fe --- /dev/null +++ b/ext/gd/tests/bug51671.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #51671 (imagefill does not work correctly for small images) +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available'); } +?> +--FILE-- +<?php +$w = 1; +$h = 50; +$im = imagecreatetruecolor($w, $h); +$white = imagecolorallocate($im, 255, 255, 255); +imagefill($im, 0, 0, $white); + +for ($iy = 0; $iy < $h; $iy++) { + if (($c = imagecolorat($im, 0, $iy)) != $white) { + printf("Failed, (0, $iy) is %X\n", $c); + } +} + +echo "OK\n"; +?> +--EXPECTF-- +OK diff --git a/ext/gd/tests/bug60160.phpt b/ext/gd/tests/bug60160.phpt new file mode 100644 index 0000000..af2df41 --- /dev/null +++ b/ext/gd/tests/bug60160.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #60160 (imagefill does not work correctly for small images) @see bug51671 +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available'); } +?> +--FILE-- +<?php +$w = 3; +$h = 50; +$im = imagecreatetruecolor($w, $h); +$white = imagecolorallocate($im, 255, 255, 255); +imagefill($im, 0, 0, $white); + +for ($ix = 0; $ix < $w; $ix++) { + for ($iy = 0; $iy < $h; $iy++) { + if (($c = imagecolorat($im, $ix, $iy)) != $white) { + printf("Failed, ($ix, $iy) is %X\n", $c); + } + } +} + +echo "OK\n"; +?> +--EXPECTF-- +OK diff --git a/ext/gd/tests/colorat.phpt b/ext/gd/tests/colorat.phpt new file mode 100644 index 0000000..be14873 --- /dev/null +++ b/ext/gd/tests/colorat.phpt @@ -0,0 +1,42 @@ +--TEST-- +imagecolorat +--SKIPIF-- +<?php + if (!function_exists('imagecolorat')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$file = dirname(__FILE__) . '/im.wbmp'; + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); +imagesetpixel($im, 3,3, 0x0); + + +echo 'test colorat truecolor: '; +$c = imagecolorat($im, 3,3); +echo $c == 0x0 ? 'ok' : 'failed'; +echo "\n"; +imagedestroy($im); + +$im = imagecreate(6,6); +$c1 = imagecolorallocate($im, 255,255,255); +$c2 = imagecolorallocate($im, 0,0,0); + +imagefill($im, 0,0, $c1); +imagesetpixel($im, 3,3, $c2); +echo 'test colorat palette: '; + +$c = imagecolorsforindex($im, imagecolorat($im, 3,3)); +$failed = false; +foreach ($c as $v) { + if ($v != 0) { + $failed = true; + } +} +echo !$failed ? 'ok' : 'failed'; +echo "\n"; +?> +--EXPECT-- +test colorat truecolor: ok +test colorat palette: ok diff --git a/ext/gd/tests/colorclosest.phpt b/ext/gd/tests/colorclosest.phpt new file mode 100644 index 0000000..7ade094 --- /dev/null +++ b/ext/gd/tests/colorclosest.phpt @@ -0,0 +1,127 @@ +--TEST-- +imageclosest +--SKIPIF-- +<?php + if (!function_exists('imagecolorclosest')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php + +$im = imagecreatetruecolor(5,5); +$c = imagecolorclosest($im, 255,0,255); +printf("%X\n", $c); +imagedestroy($im); + +$im = imagecreate(5,5); +$c = imagecolorclosest($im, 255,0,255); +print_r(imagecolorsforindex($im, $c)); +imagedestroy($im); + +$im = imagecreate(5,5); +imagecolorallocate($im, 255, 0, 255); +$c = imagecolorclosest($im, 255,0,255); +print_r(imagecolorsforindex($im, $c)); +imagedestroy($im); + +$im = imagecreate(5,5); +for ($i=0; $i<255; $i++) imagecolorresolve($im, $i,0,0); +$c = imagecolorclosest($im, 255,0,0); +print_r(imagecolorsforindex($im, $c)); + + +$im = imagecreate(5,5); +for ($i=0; $i<256; $i++) { + if ($i == 246) { + imagecolorallocate($im, $i,10,10); + } else { + imagecolorallocate($im, $i,0,0); + } +} +$c = imagecolorclosest($im, 255,10,10); +print_r(imagecolorsforindex($im, $c)); + +// with alpha +$im = imagecreatetruecolor(5,5); +$c = imagecolorclosestalpha($im, 255,0,255,100); +printf("%X\n", $c); +imagedestroy($im); + +$im = imagecreate(5,5); +$c = imagecolorclosestalpha($im, 255,0,255,100); +print_r(imagecolorsforindex($im, $c)); +imagedestroy($im); + +$im = imagecreate(5,5); +imagecolorallocatealpha($im, 255, 0, 255, 1); +$c = imagecolorclosestalpha($im, 255,0,255,1); +print_r(imagecolorsforindex($im, $c)); +imagedestroy($im); + +$im = imagecreate(5,5); +for ($i=0; $i<255; $i++) imagecolorresolvealpha($im, $i,0,0,1); +$c = imagecolorclosestalpha($im, 255,0,0,1); +print_r(imagecolorsforindex($im, $c)); + + +$im = imagecreate(5,5); +for ($i=0; $i<256; $i++) { + if ($i == 246) { + imagecolorallocatealpha($im, $i,10,10,1); + } else { + imagecolorallocatealpha($im, $i,0,0,100); + } +} +$c = imagecolorclosestalpha($im, 255,10,10,1); +print_r(imagecolorsforindex($im, $c)); + + +?> +--EXPECTF-- +FF00FF + +Warning: imagecolorsforindex(): Color index -1 out of range in %s on line %d +Array +( + [red] => 255 + [green] => 0 + [blue] => 255 + [alpha] => 0 +) +Array +( + [red] => 254 + [green] => 0 + [blue] => 0 + [alpha] => 0 +) +Array +( + [red] => 246 + [green] => 10 + [blue] => 10 + [alpha] => 0 +) +64FF00FF + +Warning: imagecolorsforindex(): Color index -1 out of range in %s on line %d +Array +( + [red] => 255 + [green] => 0 + [blue] => 255 + [alpha] => 1 +) +Array +( + [red] => 254 + [green] => 0 + [blue] => 0 + [alpha] => 1 +) +Array +( + [red] => 246 + [green] => 10 + [blue] => 10 + [alpha] => 1 +) diff --git a/ext/gd/tests/colorexact.phpt b/ext/gd/tests/colorexact.phpt new file mode 100644 index 0000000..e6983b7 --- /dev/null +++ b/ext/gd/tests/colorexact.phpt @@ -0,0 +1,40 @@ +--TEST-- +imagecolorexact +--SKIPIF-- +<?php + if (!function_exists('imagecolorexact')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php + +$im = imagecreatetruecolor(5,5); +$c = imagecolorexact($im, 255,0,255); +$c2 = imagecolorexactalpha($im, 255,0,255, 100); + +printf("%X\n", $c); +printf("%X\n", $c2); + +imagedestroy($im); + +$im = imagecreate(5,5); +$c = imagecolorallocate($im, 255,0,255); +$c2 = imagecolorallocate($im, 255,200,0); +$c3 = imagecolorallocatealpha($im, 255,200,0,100); + +echo imagecolorexact($im, 255,0,255) . "\n"; +echo imagecolorexact($im, 255,200,0) . "\n"; +echo imagecolorexactalpha($im, 255,200,0,100) . "\n"; + + +// unallocated index +echo imagecolorexact($im, 12,12,12) . "\n"; + +imagedestroy($im); +?> +--EXPECTF-- +FF00FF +64FF00FF +0 +1 +2 +-1 diff --git a/ext/gd/tests/colormatch.phpt b/ext/gd/tests/colormatch.phpt new file mode 100644 index 0000000..283a200 --- /dev/null +++ b/ext/gd/tests/colormatch.phpt @@ -0,0 +1,21 @@ +--TEST-- +imagecolormatch +--SKIPIF-- +<?php + if (!function_exists('imagecolormatch')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php + +$im = imagecreatetruecolor(5,5); +$im2 = imagecreate(5,5); + +imagecolormatch($im, $im2); + +echo "ok\n"; + +imagedestroy($im); +?> +--EXPECTF-- +Warning: imagecolormatch(): Image2 must have at least one color in %s on line %d +ok diff --git a/ext/gd/tests/colorresolve.phpt b/ext/gd/tests/colorresolve.phpt new file mode 100644 index 0000000..9af0f18 --- /dev/null +++ b/ext/gd/tests/colorresolve.phpt @@ -0,0 +1,113 @@ +--TEST-- +imagecolorresolve +--SKIPIF-- +<?php + if (!function_exists('imagecolorresolve')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php + +$im = imagecreatetruecolor(5,5); +$c = imagecolorresolve($im, 255,0,255); +printf("%X\n", $c); +imagedestroy($im); + +$im = imagecreate(5,5); +$c = imagecolorresolve($im, 255,0,255); +print_r(imagecolorsforindex($im, $c)); +imagedestroy($im); + +$im = imagecreate(5,5); +for ($i=0; $i<255; $i++) imagecolorresolve($im, $i,0,0); +$c = imagecolorresolve($im, 255,0,0); +print_r(imagecolorsforindex($im, $c)); + + +$im = imagecreate(5,5); +for ($i=0; $i<256; $i++) { + if ($i == 246) { + imagecolorresolve($im, $i,10,10); + } else { + imagecolorresolve($im, $i,0,0); + } +} +$c = imagecolorresolve($im, 255,10,10); +print_r(imagecolorsforindex($im, $c)); + + + +// with alpha +$im = imagecreatetruecolor(5,5); +$c = imagecolorresolvealpha($im, 255,0,255, 100); +printf("%X\n", $c); +imagedestroy($im); + +$im = imagecreate(5,5); +$c = imagecolorresolvealpha($im, 255,0,255,100); +print_r(imagecolorsforindex($im, $c)); +imagedestroy($im); + +$im = imagecreate(5,5); +for ($i=0; $i<255; $i++) imagecolorresolvealpha($im, $i,0,0,1); +$c = imagecolorresolvealpha($im, 255,0,0,1); +print_r(imagecolorsforindex($im, $c)); + + +$im = imagecreate(5,5); +for ($i=0; $i<256; $i++) { + if ($i == 246) { + imagecolorresolvealpha($im, $i,10,10,1); + } else { + imagecolorresolvealpha($im, $i,0,0,100); + } +} +$c = imagecolorresolvealpha($im, 255,10,10,0); +print_r(imagecolorsforindex($im, $c)); + + +?> +--EXPECTF-- +FF00FF +Array +( + [red] => 255 + [green] => 0 + [blue] => 255 + [alpha] => 0 +) +Array +( + [red] => 255 + [green] => 0 + [blue] => 0 + [alpha] => 0 +) +Array +( + [red] => 246 + [green] => 10 + [blue] => 10 + [alpha] => 0 +) +64FF00FF +Array +( + [red] => 255 + [green] => 0 + [blue] => 255 + [alpha] => 100 +) +Array +( + [red] => 255 + [green] => 0 + [blue] => 0 + [alpha] => 1 +) +Array +( + [red] => 246 + [green] => 10 + [blue] => 10 + [alpha] => 1 +) diff --git a/ext/gd/tests/conv_test.gif b/ext/gd/tests/conv_test.gif Binary files differnew file mode 100644 index 0000000..40aa433 --- /dev/null +++ b/ext/gd/tests/conv_test.gif diff --git a/ext/gd/tests/conv_test.jpeg b/ext/gd/tests/conv_test.jpeg Binary files differnew file mode 100644 index 0000000..7283d1a --- /dev/null +++ b/ext/gd/tests/conv_test.jpeg diff --git a/ext/gd/tests/conv_test.png b/ext/gd/tests/conv_test.png Binary files differnew file mode 100644 index 0000000..f8c12df --- /dev/null +++ b/ext/gd/tests/conv_test.png diff --git a/ext/gd/tests/conv_test.xbm b/ext/gd/tests/conv_test.xbm new file mode 100644 index 0000000..a916671 --- /dev/null +++ b/ext/gd/tests/conv_test.xbm @@ -0,0 +1,4 @@ +#define conv_test_xbm_width 16
+#define conv_test_xbm_height 5
+static unsigned char conv_test_xbm_bits[] = {
+ 0x4c, 0x0d, 0x54, 0x15, 0xcc, 0x0d, 0x44, 0x05, 0x44, 0x05};
\ No newline at end of file diff --git a/ext/gd/tests/conv_test.xpm b/ext/gd/tests/conv_test.xpm new file mode 100644 index 0000000..b1126c1 --- /dev/null +++ b/ext/gd/tests/conv_test.xpm @@ -0,0 +1,1588 @@ +/* XPM */ +static char * conv_test_xpm[] = { +"50 50 1535 2", +" c None", +". c #F81010", +"+ c #F71112", +"@ c #F51314", +"# c #F31517", +"$ c #F01619", +"% c #EE181C", +"& c #EC191E", +"* c #E91B21", +"= c #E71D24", +"- c #E41E26", +"; c #E22028", +"> c #E0212B", +", c #DE232D", +"' c #DB2430", +") c #D92632", +"! c #D62835", +"~ c #D42938", +"{ c #D22B3A", +"] c #CF2C3D", +"^ c #CD2E3F", +"/ c #CB2F41", +"( c #C93144", +"_ c #C63346", +": c #C43449", +"< c #C1364C", +"[ c #BF374E", +"} c #BD3951", +"| c #BB3B53", +"1 c #B83C55", +"2 c #B63E58", +"3 c #B43F5A", +"4 c #B1415D", +"5 c #AF4360", +"6 c #AC4462", +"7 c #AA4665", +"8 c #A84767", +"9 c #A6496A", +"0 c #A34A6C", +"a c #A14C6E", +"b c #9F4D71", +"c c #9C4F74", +"d c #9A5176", +"e c #975279", +"f c #95547B", +"g c #93557E", +"h c #F71212", +"i c #F51315", +"j c #F21517", +"k c #F0161A", +"l c #EB191E", +"m c #E22029", +"n c #DD232E", +"o c #D92633", +"p c #D42A38", +"q c #CF2D3D", +"r c #CD2F3F", +"s c #CB3142", +"t c #C83244", +"u c #C63347", +"v c #C43549", +"w c #BF384E", +"x c #BA3B53", +"y c #B83C56", +"z c #B33F5B", +"A c #A5496A", +"B c #A14C6F", +"C c #9E4E71", +"D c #93567E", +"E c #905780", +"F c #F41315", +"G c #EB191F", +"H c #E61D24", +"I c #DB2530", +"J c #D92733", +"K c #D62936", +"L c #D22C3A", +"M c #D02E3D", +"N c #CD303F", +"O c #C93344", +"P c #C73447", +"Q c #C53649", +"R c #C2384C", +"S c #C0394F", +"T c #BD3A51", +"U c #BB3C53", +"V c #B83D56", +"W c #B63F58", +"X c #B3405B", +"Y c #AE4360", +"Z c #AC4463", +"` c #A74767", +" . c #A34B6C", +".. c #995177", +"+. c #975379", +"@. c #95547C", +"#. c #8E5983", +"$. c #F71213", +"%. c #ED181C", +"&. c #EB1A1F", +"*. c #E91B22", +"=. c #E41E27", +"-. c #DF222C", +";. c #DB2630", +">. c #D82833", +",. c #D42B38", +"'. c #D22D3B", +"). c #D02F3D", +"!. c #CE3040", +"~. c #CB3242", +"{. c #C93444", +"]. c #C73547", +"^. c #C53749", +"/. c #C03A4F", +"(. c #BE3B51", +"_. c #BB3D54", +":. c #B93E56", +"<. c #B64059", +"[. c #B4415B", +"}. c #B2425D", +"|. c #AF4460", +"1. c #AC4563", +"2. c #A74868", +"3. c #A34B6D", +"4. c #A04C6F", +"5. c #9E4E72", +"6. c #9C5074", +"7. c #92567E", +"8. c #905781", +"9. c #8B5B86", +"0. c #F61213", +"a. c #F21518", +"b. c #F0171A", +"c. c #ED181D", +"d. c #E81B22", +"e. c #E41F27", +"f. c #E12029", +"g. c #DD242E", +"h. c #DB2631", +"i. c #D62A36", +"j. c #D42C38", +"k. c #D22E3B", +"l. c #D0303D", +"m. c #CD3140", +"n. c #CB3342", +"o. c #C93545", +"p. c #C73647", +"q. c #C5384A", +"r. c #C3394C", +"s. c #C03B4F", +"t. c #BE3D51", +"u. c #BC3E54", +"v. c #BA3F56", +"w. c #B74159", +"x. c #B5425B", +"y. c #B2435E", +"z. c #B04560", +"A. c #AD4663", +"B. c #AA4765", +"C. c #A84868", +"D. c #9B5075", +"E. c #94547C", +"F. c #905881", +"G. c #895C88", +"H. c #F81111", +"I. c #F41415", +"J. c #EF171A", +"K. c #E81C22", +"L. c #E61D25", +"M. c #DA2731", +"N. c #D92933", +"O. c #D42D39", +"P. c #D0303E", +"Q. c #CD3240", +"R. c #C33A4D", +"S. c #BE3D52", +"T. c #B94056", +"U. c #B04561", +"V. c #AE4763", +"W. c #AB4866", +"X. c #A94A68", +"Y. c #A64B6B", +"Z. c #A34C6D", +"`. c #A14D6F", +" + c #97537A", +".+ c #94557C", +"++ c #92567F", +"@+ c #8D5983", +"#+ c #865E8B", +"$+ c #F41416", +"%+ c #F11518", +"&+ c #EF171B", +"*+ c #E31F27", +"=+ c #E1202A", +"-+ c #DF232C", +";+ c #DC252F", +">+ c #D62B36", +",+ c #D22F3B", +"'+ c #CF303E", +")+ c #CB3343", +"!+ c #C73648", +"~+ c #C23A4D", +"{+ c #BB3E54", +"]+ c #B94057", +"^+ c #B5425C", +"/+ c #B2445E", +"(+ c #AC4866", +"_+ c #AA4A68", +":+ c #A74C6B", +"<+ c #A44D6D", +"[+ c #A24E70", +"}+ c #9F4F72", +"|+ c #9C5075", +"1+ c #995277", +"2+ c #96537A", +"3+ c #8D5984", +"4+ c #895C89", +"5+ c #84608E", +"6+ c #ED191D", +"7+ c #EA1A20", +"8+ c #E1212A", +"9+ c #D92934", +"0+ c #C83545", +"a+ c #B74259", +"b+ c #B4425C", +"c+ c #AE4764", +"d+ c #AC4966", +"e+ c #A54D6D", +"f+ c #A34F70", +"g+ c #A05072", +"h+ c #9D5275", +"i+ c #9A5378", +"j+ c #97547A", +"k+ c #8F5881", +"l+ c #885D89", +"m+ c #865E8C", +"n+ c #816191", +"o+ c #F11618", +"p+ c #EC191D", +"q+ c #E81C23", +"r+ c #E51E25", +"s+ c #E31F28", +"t+ c #D92A34", +"u+ c #D62C37", +"v+ c #D12F3C", +"w+ c #CD3241", +"x+ c #CA3343", +"y+ c #C73748", +"z+ c #C03B50", +"A+ c #BD3D52", +"B+ c #BB3F55", +"C+ c #B6425A", +"D+ c #B4435C", +"E+ c #AF4661", +"F+ c #AD4764", +"G+ c #A94A69", +"H+ c #A54D6E", +"I+ c #9E5275", +"J+ c #9B5478", +"K+ c #99557A", +"L+ c #96567D", +"M+ c #93577F", +"N+ c #905882", +"O+ c #8D5A84", +"P+ c #8B5B87", +"Q+ c #83608E", +"R+ c #816291", +"S+ c #7F6393", +"T+ c #E71C23", +"U+ c #DC262F", +"V+ c #DA2832", +"W+ c #D82A34", +"X+ c #D32D39", +"Y+ c #CA3443", +"Z+ c #C83546", +"`+ c #C4394B", +" @ c #C23B4E", +".@ c #C03D51", +"+@ c #BE3F54", +"@@ c #BC4157", +"#@ c #BA435A", +"$@ c #B7445C", +"%@ c #B5455F", +"&@ c #B24661", +"*@ c #B04763", +"=@ c #AE4865", +"-@ c #A24F70", +";@ c #A05173", +">@ c #97577D", +",@ c #94587F", +"'@ c #915982", +")@ c #8E5B84", +"!@ c #865F8C", +"~@ c #7C6596", +"{@ c #E51E26", +"]@ c #E0212A", +"^@ c #D32D3A", +"/@ c #CF313E", +"(@ c #CC3241", +"_@ c #C63749", +":@ c #C43A4D", +"<@ c #C23D50", +"[@ c #C03F53", +"}@ c #BE4157", +"|@ c #BC4359", +"1@ c #BA455C", +"2@ c #B8465F", +"3@ c #B64861", +"4@ c #B44964", +"5@ c #B14A66", +"6@ c #AF4B68", +"7@ c #AD4C6A", +"8@ c #AA4D6B", +"9@ c #A74E6D", +"0@ c #A54E6E", +"a@ c #9D5276", +"b@ c #99567B", +"c@ c #96577D", +"d@ c #945980", +"e@ c #925A82", +"f@ c #8F5C84", +"g@ c #8C5C87", +"h@ c #895E89", +"i@ c #83608F", +"j@ c #7E6394", +"k@ c #7A6698", +"l@ c #EA1B20", +"m@ c #E21F28", +"n@ c #DC2530", +"o@ c #D52C37", +"p@ c #D32E3A", +"q@ c #CE313F", +"r@ c #CA3444", +"s@ c #C83646", +"t@ c #C6394A", +"u@ c #C53B4E", +"v@ c #C33E52", +"w@ c #C14155", +"x@ c #BF4358", +"y@ c #BD455C", +"z@ c #BB475F", +"A@ c #B94961", +"B@ c #B74B64", +"C@ c #B54C66", +"D@ c #B34D68", +"E@ c #B04F6B", +"F@ c #AE4F6C", +"G@ c #AC506E", +"H@ c #A95170", +"I@ c #A65272", +"J@ c #A35273", +"K@ c #A05274", +"L@ c #9D5376", +"M@ c #905C85", +"N@ c #8E5E87", +"O@ c #8A5F8A", +"P@ c #87608C", +"Q@ c #84618F", +"R@ c #7E6494", +"S@ c #7A6799", +"T@ c #77689B", +"U@ c #D92832", +"V@ c #D82A35", +"W@ c #C83647", +"X@ c #C6394B", +"Y@ c #C53D4F", +"Z@ c #C33F53", +"`@ c #C14257", +" # c #C0445A", +".# c #BE475D", +"+# c #BC4961", +"@# c #BA4B63", +"## c #B84D66", +"$# c #B64F69", +"%# c #B4506B", +"&# c #B2526D", +"*# c #AF536F", +"=# c #AD5471", +"-# c #AB5473", +";# c #A85574", +"># c #A55576", +",# c #A25678", +"'# c #9F5679", +")# c #9C567A", +"!# c #925B82", +"~# c #8C5F8A", +"{# c #88618D", +"]# c #86628F", +"^# c #826392", +"/# c #7F6494", +"(# c #796799", +"_# c #756A9E", +":# c #D72A35", +"<# c #D52C38", +"[# c #CC3342", +"}# c #C83747", +"|# c #C63A4B", +"1# c #C53D50", +"2# c #C34054", +"3# c #C24358", +"4# c #C0455B", +"5# c #BE485F", +"6# c #BC4B62", +"7# c #BB4D65", +"8# c #B94F68", +"9# c #B7516B", +"0# c #B5536E", +"a# c #B35470", +"b# c #B05672", +"c# c #AE5774", +"d# c #AD5876", +"e# c #AA5878", +"f# c #A75979", +"g# c #A4597A", +"h# c #A15A7C", +"i# c #9E5A7D", +"j# c #9B5A7E", +"k# c #975A80", +"l# c #945A81", +"m# c #915B83", +"n# c #8B5F8A", +"o# c #89618D", +"p# c #86638F", +"q# c #846492", +"r# c #806594", +"s# c #7D6697", +"t# c #77689C", +"u# c #726CA1", +"v# c #C63A4C", +"w# c #C34154", +"x# c #C0465C", +"y# c #BE4960", +"z# c #BD4C64", +"A# c #BB4F67", +"B# c #BA516A", +"C# c #B8536D", +"D# c #B65570", +"E# c #B45772", +"F# c #B25975", +"G# c #B05A77", +"H# c #AD5B79", +"I# c #AC5C7B", +"J# c #A95C7C", +"K# c #A65D7E", +"L# c #A35D7F", +"M# c #A05D80", +"N# c #9D5D81", +"O# c #9A5D82", +"P# c #965D83", +"Q# c #935D85", +"R# c #905D86", +"S# c #8D5E88", +"T# c #826694", +"U# c #7E6797", +"V# c #7B6899", +"W# c #78699C", +"X# c #706DA3", +"Y# c #DF212B", +"Z# c #D62935", +"`# c #C43D50", +" $ c #C34155", +".$ c #C14459", +"+$ c #C0475D", +"@$ c #BF4A61", +"#$ c #BD4D65", +"$$ c #BC5068", +"%$ c #BA536C", +"&$ c #BA5870", +"*$ c #B95C75", +"=$ c #B85E79", +"-$ c #B6607B", +";$ c #B4617D", +">$ c #B2627F", +",$ c #B06380", +"'$ c #AD6280", +")$ c #A96080", +"!$ c #A56082", +"~$ c #A26183", +"{$ c #9F6184", +"]$ c #9C6185", +"^$ c #996186", +"/$ c #956187", +"($ c #926088", +"_$ c #8F6089", +":$ c #8B608B", +"<$ c #866390", +"[$ c #826695", +"}$ c #7F6897", +"|$ c #7D6999", +"1$ c #796A9C", +"2$ c #766B9E", +"3$ c #6F6EA4", +"4$ c #6D6FA6", +"5$ c #DB2531", +"6$ c #D82733", +"7$ c #CE3140", +"8$ c #C93445", +"9$ c #C5394B", +"0$ c #C14359", +"a$ c #BF4B61", +"b$ c #BD4E66", +"c$ c #BC5169", +"d$ c #BC566D", +"e$ c #BC5B74", +"f$ c #B95C77", +"g$ c #B85D78", +"h$ c #B65F79", +"i$ c #B4617C", +"j$ c #B2627E", +"k$ c #AE6483", +"l$ c #AC6686", +"m$ c #AB6888", +"n$ c #A76787", +"o$ c #A26487", +"p$ c #9E6488", +"q$ c #9B6489", +"r$ c #98648A", +"s$ c #94648B", +"t$ c #91638C", +"u$ c #8D638D", +"v$ c #8A638E", +"w$ c #846592", +"x$ c #816695", +"y$ c #7D699A", +"z$ c #7A6B9C", +"A$ c #776C9F", +"B$ c #746DA1", +"C$ c #706EA4", +"D$ c #6B71A9", +"E$ c #DA2531", +"F$ c #D82633", +"G$ c #C43C4F", +"H$ c #C24054", +"I$ c #C14358", +"J$ c #BE4A61", +"K$ c #BC516A", +"L$ c #BD586F", +"M$ c #BB5B76", +"N$ c #BA5C76", +"O$ c #B95F78", +"P$ c #B8617B", +"Q$ c #B6637E", +"R$ c #B56580", +"S$ c #B36783", +"T$ c #B16885", +"U$ c #AF6986", +"V$ c #AC6988", +"W$ c #A96989", +"X$ c #A66A8D", +"Y$ c #A56B8D", +"Z$ c #9E688C", +"`$ c #9A678D", +" % c #96678E", +".% c #93678F", +"+% c #906690", +"@% c #8C6691", +"#% c #886692", +"$% c #846593", +"%% c #786C9F", +"&% c #756EA2", +"*% c #726FA4", +"=% c #6E6FA7", +"-% c #6872AB", +";% c #D62836", +">% c #D32B39", +",% c #D02F3E", +"'% c #C33B4E", +")% c #C23F53", +"!% c #C04358", +"~% c #BF465C", +"{% c #BA5D76", +"]% c #B96079", +"^% c #B9637D", +"/% c #B96680", +"(% c #B96883", +"_% c #B86A86", +":% c #B66C88", +"<% c #B46D8A", +"[% c #B06D8B", +"}% c #AD6D8C", +"|% c #AA6D8D", +"1% c #A66D8E", +"2% c #A26D91", +"3% c #A06E92", +"4% c #996A91", +"5% c #956A91", +"6% c #926992", +"7% c #8F6993", +"8% c #8B6994", +"9% c #876895", +"0% c #826896", +"a% c #7F6898", +"b% c #7C699A", +"c% c #7A6B9D", +"d% c #786D9F", +"e% c #766EA2", +"f% c #7370A4", +"g% c #7070A7", +"h% c #6C71A9", +"i% c #6873AC", +"j% c #6674AE", +"k% c #D32A39", +"l% c #D12D3B", +"m% c #CF2F3E", +"n% c #C13E52", +"o% c #C04256", +"p% c #BE455B", +"q% c #BD4960", +"r% c #BC4D65", +"s% c #BB5069", +"t% c #BB566E", +"u% c #BA6079", +"v% c #BA647E", +"w% c #BB6882", +"x% c #BD6B86", +"y% c #BD6E89", +"z% c #BE708C", +"A% c #BC718E", +"B% c #B9728F", +"C% c #B57290", +"D% c #B07191", +"E% c #AC7191", +"F% c #A67092", +"G% c #A26F93", +"H% c #9E7096", +"I% c #9B7095", +"J% c #946D95", +"K% c #916C96", +"L% c #8D6C96", +"M% c #896B97", +"N% c #856B98", +"O% c #816A99", +"P% c #7D6A9B", +"Q% c #766FA2", +"R% c #7470A4", +"S% c #7172A7", +"T% c #6E72A9", +"U% c #6A73AC", +"V% c #6376B1", +"W% c #D02C3B", +"X% c #CF2E3E", +"Y% c #C03C50", +"Z% c #BF4055", +"`% c #BE445A", +" & c #BC485F", +".& c #BB4C63", +"+& c #BA4F68", +"@& c #BA536D", +"#& c #BB5C75", +"$& c #B95C76", +"%& c #B9607A", +"&& c #BC6882", +"*& c #BF6C87", +"=& c #C1708B", +"-& c #C5778F", +";& c #C97D92", +">& c #C77F94", +",& c #C27C95", +"'& c #BB7896", +")& c #B47696", +"!& c #AE7596", +"~& c #A87496", +"{& c #A27396", +"]& c #9D7297", +"^& c #9B739A", +"/& c #947098", +"(& c #906F99", +"_& c #8C6E9A", +":& c #886E9B", +"<& c #836D9B", +"[& c #7F6D9C", +"}& c #7B6C9D", +"|& c #776D9F", +"1& c #7470A5", +"2& c #6F73AA", +"3& c #6C74AC", +"4& c #6875AE", +"5& c #6476B1", +"6& c #6178B3", +"7& c #D02C3C", +"8& c #CE2E3E", +"9& c #CC3041", +"0& c #C4384A", +"a& c #BD4259", +"b& c #BB465E", +"c& c #BA4A62", +"d& c #B94E67", +"e& c #B8526B", +"f& c #B95870", +"g& c #B95D78", +"h& c #B85F79", +"i& c #C3738C", +"j& c #CD8091", +"k& c #D18695", +"l& c #D18998", +"m& c #D08A9B", +"n& c #CE8A9B", +"o& c #C9879B", +"p& c #BB7D9B", +"q& c #B1799A", +"r& c #AA779A", +"s& c #A37699", +"t& c #9C759A", +"u& c #98749C", +"v& c #95759C", +"w& c #8E719C", +"x& c #8A709D", +"y& c #86709E", +"z& c #826F9F", +"A& c #7D6FA0", +"B& c #796FA1", +"C& c #7370A5", +"D& c #6C75AC", +"E& c #6A76AF", +"F& c #6677B1", +"G& c #6278B4", +"H& c #5E79B6", +"I& c #CE2D3E", +"J& c #CA3243", +"K& c #C83446", +"L& c #C4384B", +"M& c #BF3C50", +"N& c #BB4157", +"O& c #BA445C", +"P& c #B94861", +"Q& c #B84C65", +"R& c #B7506A", +"S& c #B7546F", +"T& c #B85D76", +"U& c #B65E79", +"V& c #B7627C", +"W& c #B96681", +"X& c #BC6B86", +"Y& c #C1718B", +"Z& c #D28897", +"`& c #D991A0", +" * c #DE98A9", +".* c #DE9AAB", +"+* c #D895A6", +"@* c #CE8EA1", +"#* c #C88A9F", +"$* c #B57E9E", +"%* c #AC7A9D", +"&* c #A3789D", +"** c #9C779D", +"=* c #96769E", +"-* c #9578A1", +";* c #8D739F", +">* c #8873A0", +",* c #8472A0", +"'* c #8072A2", +")* c #7B71A3", +"!* c #7771A4", +"~* c #6F74AA", +"{* c #6A77AF", +"]* c #6778B1", +"^* c #6379B4", +"/* c #607AB7", +"(* c #5C7BB9", +"_* c #C93143", +":* c #C63648", +"<* c #BD3D53", +"[* c #B9425A", +"}* c #B74A63", +"|* c #B64E68", +"1* c #B5526D", +"2* c #B55672", +"3* c #B75F7A", +"4* c #B5607B", +"5* c #B6647F", +"6* c #B86984", +"7* c #C5788F", +"8* c #E4A1B2", +"9* c #ECB7C4", +"0* c #ECBAC7", +"a* c #E4A8BA", +"b* c #D898AB", +"c* c #CB8EA3", +"d* c #BC86A2", +"e* c #AD7DA1", +"f* c #A47BA0", +"g* c #9B79A0", +"h* c #9578A0", +"i* c #9379A4", +"j* c #8C76A2", +"k* c #8675A3", +"l* c #8274A3", +"m* c #7E73A4", +"n* c #7973A5", +"o* c #7573A6", +"p* c #7172A8", +"q* c #6E74AA", +"r* c #6C75AD", +"s* c #6878B2", +"t* c #6579B4", +"u* c #617BB7", +"v* c #5D7BB9", +"w* c #597DBC", +"x* c #C73346", +"y* c #C3384B", +"z* c #C23A4E", +"A* c #BA3F55", +"B* c #B84158", +"C* c #B7445D", +"D* c #B64862", +"E* c #B35874", +"F* c #B5617C", +"G* c #B3627D", +"H* c #B46682", +"I* c #B76B87", +"J* c #BD708C", +"K* c #C87E93", +"L* c #D18999", +"M* c #F9E0E6", +"N* c #FAE6EB", +"O* c #EEC2CE", +"P* c #DDA1B5", +"Q* c #CC91A8", +"R* c #C18BA5", +"S* c #AE7FA3", +"T* c #A37DA2", +"U* c #9A7BA2", +"V* c #937AA3", +"W* c #917BA6", +"X* c #8B78A4", +"Y* c #8476A5", +"Z* c #8076A6", +"`* c #7C75A7", +" = c #7775A8", +".= c #7375A9", +"+= c #6778B2", +"@= c #657AB4", +"#= c #627BB7", +"$= c #5F7CB9", +"%= c #5B7DBC", +"&= c #577EBE", +"*= c #C3374B", +"== c #C13A4E", +"-= c #BF3C51", +";= c #BD3E53", +">= c #B6425B", +",= c #B4465F", +"'= c #B34A64", +")= c #B24E69", +"!= c #B2526E", +"~= c #B15672", +"{= c #B15A77", +"]= c #B3627F", +"^= c #B16380", +"/= c #B26784", +"(= c #B66D89", +"_= c #BB728F", +":= c #C77F95", +"<= c #D08B9B", +"[= c #FBEBF0", +"}= c #EEC6D1", +"|= c #DDA2B7", +"1= c #CC93AA", +"2= c #BF8CA7", +"3= c #AC81A6", +"4= c #A17FA5", +"5= c #987DA5", +"6= c #927BA5", +"7= c #8F7CA8", +"8= c #8879A7", +"9= c #8278A8", +"0= c #7E78A9", +"a= c #7977AA", +"b= c #7576AB", +"c= c #7176AC", +"d= c #6C76AD", +"e= c #6977AF", +"f= c #6779B2", +"g= c #627CB7", +"h= c #607DBA", +"i= c #5C7EBC", +"j= c #587FBF", +"k= c #5580C1", +"l= c #C2364B", +"m= c #C0394E", +"n= c #BF3B51", +"o= c #BC3E53", +"p= c #B3435D", +"q= c #B24762", +"r= c #B14B66", +"s= c #AF5370", +"t= c #AE5775", +"u= c #AE5B79", +"v= c #B16381", +"w= c #AF6482", +"x= c #B06986", +"y= c #B36D8B", +"z= c #B87290", +"A= c #C17D96", +"B= c #CE8A9C", +"C= c #D895A7", +"D= c #E5AFC2", +"E= c #D79DB2", +"F= c #C891AA", +"G= c #BA8AA8", +"H= c #A981A7", +"I= c #9F80A7", +"J= c #967EA7", +"K= c #907DA8", +"L= c #8D7EAB", +"M= c #857AA9", +"N= c #8079AA", +"O= c #7B79AB", +"P= c #7778AC", +"Q= c #7378AD", +"R= c #6E78AE", +"S= c #6A77B0", +"T= c #657AB5", +"U= c #607EBA", +"V= c #5D7EBC", +"W= c #5A80BF", +"X= c #5681C1", +"Y= c #5282C4", +"Z= c #BC3D53", +"`= c #B14560", +" - c #AF4864", +".- c #AE4C69", +"+- c #AE506D", +"@- c #AD5472", +"#- c #AD5877", +"$- c #AD6585", +"%- c #AD6988", +"&- c #AF6E8C", +"*- c #B37391", +"=- c #BA7896", +"-- c #C8889C", +";- c #CE8EA2", +">- c #DDA3B7", +",- c #CC95AC", +"'- c #C390AA", +")- c #AF84A9", +"!- c #A481A8", +"~- c #9A80A8", +"{- c #937FA9", +"]- c #8D7DAA", +"^- c #8B7FAD", +"/- c #827BAB", +"(- c #7D7BAC", +"_- c #787AAD", +":- c #757AAE", +"<- c #7079B0", +"[- c #6C79B1", +"}- c #647AB5", +"|- c #627CB8", +"1- c #5D7FBD", +"2- c #5B80BF", +"3- c #5781C1", +"4- c #5382C4", +"5- c #5083C6", +"6- c #BC3A51", +"7- c #BB3C54", +"8- c #BA3E56", +"9- c #B74158", +"0- c #AE4662", +"a- c #AD4966", +"b- c #AC4E6B", +"c- c #AC5270", +"d- c #AB5574", +"e- c #AA5979", +"f- c #AA5D7D", +"g- c #AB6482", +"h- c #AB6788", +"i- c #AB6A89", +"j- c #AC6E8E", +"k- c #AF7292", +"l- c #B37797", +"m- c #BA7E9C", +"n- c #C78AA0", +"o- c #CB8EA4", +"p- c #CC92A8", +"q- c #C892AA", +"r- c #B387AA", +"s- c #A882AA", +"t- c #9E81AA", +"u- c #9580AA", +"v- c #8F7FAA", +"w- c #8A7EAC", +"x- c #8880AD", +"y- c #7E7CAD", +"z- c #7A7CAE", +"A- c #767BB0", +"B- c #727BB1", +"C- c #6D7BB2", +"D- c #697BB3", +"E- c #647BB5", +"F- c #5F7EBA", +"G- c #5B81BF", +"H- c #5882C2", +"I- c #5583C4", +"J- c #5184C7", +"K- c #4D85C9", +"L- c #BC3951", +"M- c #BA3B54", +"N- c #B74059", +"O- c #B3435E", +"P- c #AE4663", +"Q- c #AC4865", +"R- c #AB4B68", +"S- c #AA4F6D", +"T- c #A95372", +"U- c #A85676", +"V- c #A75A7B", +"W- c #A75E7F", +"X- c #A76283", +"Y- c #A96A8A", +"Z- c #A76A8B", +"`- c #A86E8F", +" ; c #AA7293", +".; c #AD7697", +"+; c #B07A9B", +"@; c #B57F9F", +"#; c #BC87A3", +"$; c #C08BA5", +"%; c #BA8AA9", +"&; c #A782AA", +"*; c #9F81AA", +"=; c #9781AB", +"-; c #9180AB", +";; c #8B80AC", +">; c #8981AF", +",; c #827EAE", +"'; c #7B7DAF", +"); c #777DB0", +"!; c #737CB2", +"~; c #6F7CB3", +"{; c #6A7CB4", +"]; c #667CB6", +"^; c #5D80BD", +"/; c #5982C2", +"(; c #5683C4", +"_; c #5284C7", +":; c #4E85C9", +"<; c #4A87CC", +"[; c #B73D56", +"}; c #B63F59", +"|; c #B4425B", +"1; c #A84C6B", +"2; c #A7506F", +"3; c #A65373", +"4; c #A55778", +"5; c #A45B7C", +"6; c #A45E80", +"7; c #A36285", +"8; c #A56889", +"9; c #A56B8F", +"0; c #A46E90", +"a; c #A57193", +"b; c #A77597", +"c; c #A9789B", +"d; c #AB7B9F", +"e; c #AD7EA2", +"f; c #AD80A4", +"g; c #AC81A7", +"h; c #A981A8", +"i; c #A481A9", +"j; c #9D81AA", +"k; c #9281AC", +"l; c #8C80AD", +"m; c #8880AF", +"n; c #8681B0", +"o; c #7C7EB0", +"p; c #787EB1", +"q; c #747EB2", +"r; c #707DB4", +"s; c #6C7DB5", +"t; c #677DB7", +"u; c #627DB8", +"v; c #5F7EBB", +"w; c #5B81C0", +"x; c #5385C7", +"y; c #4F86C9", +"z; c #4B87CC", +"A; c #4789CF", +"B; c #B73D57", +"C; c #B53E59", +"D; c #B3415C", +"E; c #B1435E", +"F; c #A45071", +"G; c #A35475", +"H; c #A25879", +"I; c #A15B7E", +"J; c #A05F82", +"K; c #A06286", +"L; c #9F668A", +"M; c #A26D8F", +"N; c #A06E93", +"O; c #A07195", +"P; c #A07498", +"Q; c #A1779B", +"R; c #A2799E", +"S; c #A37CA1", +"T; c #A27EA4", +"U; c #A17FA6", +"V; c #9E80A8", +"W; c #9981A9", +"X; c #9181AC", +"Y; c #8782B1", +"Z; c #7E7FB1", +"`; c #797FB2", +" > c #757FB3", +".> c #717EB5", +"+> c #6D7EB6", +"@> c #687EB7", +"#> c #647EB9", +"$> c #5783C5", +"%> c #5485C7", +"&> c #5087CA", +"*> c #4C87CC", +"=> c #4889CF", +"-> c #458AD1", +";> c #B53F59", +">> c #B2405C", +",> c #B0425E", +"'> c #AF4461", +")> c #A15173", +"!> c #A05577", +"~> c #9F587B", +"{> c #9E5C7F", +"]> c #9D5F83", +"^> c #9D6387", +"/> c #9C668B", +"(> c #9C698F", +"_> c #9E7094", +":> c #9C7198", +"<> c #9B7399", +"[> c #9B769C", +"}> c #9B789F", +"|> c #9A7AA1", +"1> c #997CA4", +"2> c #977DA6", +"3> c #957FA8", +"4> c #927FAA", +"5> c #8F80AB", +"6> c #8B80AD", +"7> c #8880B0", +"8> c #8682B1", +"9> c #7E80B1", +"0> c #767FB4", +"a> c #727FB5", +"b> c #6D7FB6", +"c> c #697FB8", +"d> c #647FBA", +"e> c #607FBB", +"f> c #5C80BD", +"g> c #5784C5", +"h> c #5187CA", +"i> c #4D88CC", +"j> c #4989CF", +"k> c #458BD2", +"l> c #428CD4", +"m> c #AE4461", +"n> c #AC4663", +"o> c #9C5579", +"p> c #9C597D", +"q> c #9B5C81", +"r> c #9A5F85", +"s> c #996389", +"t> c #98668C", +"u> c #976990", +"v> c #976C93", +"w> c #997197", +"x> c #99759C", +"y> c #96759E", +"z> c #9577A0", +"A> c #9379A2", +"B> c #917CA7", +"C> c #8F7DA9", +"D> c #8C7EAA", +"E> c #897FAD", +"F> c #8881B0", +"G> c #8582B1", +"H> c #7D7FB1", +"I> c #797FB3", +"J> c #757FB4", +"K> c #6E80B7", +"L> c #6A7FB8", +"M> c #6580BA", +"N> c #6180BC", +"O> c #5D80BE", +"P> c #5982C3", +"Q> c #5684C5", +"R> c #5485C8", +"S> c #4E88CC", +"T> c #4A8ACF", +"U> c #468BD2", +"V> c #408ED7", +"W> c #B0425F", +"X> c #AD4361", +"Y> c #AB4564", +"Z> c #A94766", +"`> c #A84969", +" , c #A64C6B", +"., c #99567A", +"+, c #98597E", +"@, c #975C82", +"#, c #966086", +"$, c #95638A", +"%, c #94668E", +"&, c #946991", +"*, c #936C94", +"=, c #926E98", +"-, c #92719A", +";, c #94769E", +">, c #9479A2", +",, c #927AA5", +"', c #8E7DAA", +"), c #8C7FAC", +"!, c #8A80AE", +"~, c #8780AE", +"{, c #817FAF", +"], c #7C7EB1", +"^, c #787FB2", +"/, c #727FB6", +"(, c #6A80B9", +"_, c #6680BA", +":, c #5882C3", +"<, c #5287CA", +"[, c #4E88CD", +"}, c #4B8ACF", +"|, c #478BD2", +"1, c #438CD4", +"2, c #3D8FD9", +"3, c #AD4461", +"4, c #A74969", +"5, c #A54B6B", +"6, c #A44D6E", +"7, c #955980", +"8, c #945D84", +"9, c #936087", +"0, c #92638B", +"a, c #91668F", +"b, c #906992", +"c, c #906C96", +"d, c #8F6E99", +"e, c #8D709C", +"f, c #8C739E", +"g, c #8B75A1", +"h, c #8A77A4", +"i, c #8979A6", +"j, c #877AA8", +"k, c #847BAB", +"l, c #807CAD", +"m, c #7D7DAF", +"n, c #7A7EB1", +"o, c #777EB2", +"p, c #717FB5", +"q, c #6D80B7", +"r, c #6580BB", +"s, c #6181BC", +"t, c #5D81BE", +"u, c #5A81C1", +"v, c #4F89CD", +"w, c #4B8AD0", +"x, c #488BD2", +"y, c #438CD5", +"z, c #3D90D9", +"A, c #3B91DC", +"B, c #A64969", +"C, c #A44A6C", +"D, c #A24C6E", +"E, c #A14E71", +"F, c #9F5173", +"G, c #905D85", +"H, c #906089", +"I, c #8F638C", +"J, c #8E6690", +"K, c #8D6893", +"L, c #8C6B97", +"M, c #8A6E9A", +"N, c #89709D", +"O, c #8872A0", +"P, c #8674A2", +"Q, c #8278A7", +"R, c #8079A9", +"S, c #7E7BAC", +"T, c #7B7CAE", +"U, c #797DB0", +"V, c #767EB2", +"W, c #747EB4", +"X, c #707FB6", +"Y, c #6980B9", +"Z, c #5684C6", +"`, c #5386C8", +" ' c #5187CB", +".' c #4C8AD0", +"+' c #488CD2", +"@' c #448DD5", +"#' c #3D90DA", +"$' c #3B91DD", +"%' c #9E5073", +"&' c #9C5276", +"*' c #98567B", +"=' c #8C608A", +"-' c #8B638E", +";' c #8A6691", +">' c #896894", +",' c #876B98", +"'' c #866D9B", +")' c #85709E", +"!' c #8372A1", +"~' c #7E77A8", +"{' c #7C79AB", +"]' c #797AAD", +"^' c #777BAF", +"/' c #757CB1", +"(' c #727DB3", +"_' c #6F7EB5", +":' c #6C7FB7", +"<' c #6880B9", +"[' c #6181BD", +"}' c #5883C3", +"|' c #4C8BD0", +"1' c #488CD3", +"2' c #458DD5", +"3' c #418ED7", +"4' c #9C4F73", +"5' c #9B5176", +"6' c #995378", +"7' c #98557B", +"8' c #96577E", +"9' c #925B83", +"0' c #89618C", +"a' c #87638F", +"b' c #866692", +"c' c #846896", +"d' c #836B99", +"e' c #826D9C", +"f' c #806F9F", +"g' c #7F72A2", +"h' c #7D73A4", +"i' c #7B75A7", +"j' c #737BB1", +"k' c #707CB3", +"l' c #6D7DB5", +"m' c #6A7EB7", +"n' c #677FB8", +"o' c #6380BB", +"p' c #6080BD", +"q' c #5C81BF", +"r' c #5883C4", +"s' c #5584C6", +"t' c #498CD3", +"u' c #458ED5", +"v' c #418ED8", +"w' c #985279", +"x' c #96547B", +"y' c #95577E", +"z' c #935980", +"A' c #8E5E88", +"B' c #806897", +"C' c #7F6A9A", +"D' c #7D6D9D", +"E' c #7C6FA0", +"F' c #7A71A3", +"G' c #7873A6", +"H' c #7577AB", +"I' c #717AB0", +"J' c #6E7BB2", +"K' c #6B7CB4", +"L' c #697DB6", +"M' c #657EB8", +"N' c #627FBA", +"O' c #5F80BC", +"P' c #5386C9", +"Q' c #5188CB", +"R' c #4E89CE", +"S' c #418FD8", +"T' c #3E90DA", +"U' c #925880", +"V' c #905A83", +"W' c #8F5C85", +"X' c #8B608A", +"Y' c #7B6B9C", +"Z' c #796D9F", +"`' c #776FA1", +" ) c #7671A4", +".) c #7573A7", +"+) c #7375AA", +"@) c #6E78AF", +"#) c #647DB8", +"$) c #5E7FBD", +"%) c #5A81C2", +"&) c #5783C4", +"*) c #5585C6", +"=) c #5088CB", +"-) c #4C8BD1", +";) c #498DD3", +">) c #458ED6", +",) c #8D5B86", +"') c #8B5D88", +")) c #766EA1", +"!) c #756FA3", +"~) c #7271A6", +"{) c #7073A9", +"]) c #6E75AB", +"^) c #6C76AE", +"/) c #6978B0", +"() c #6779B3", +"_) c #5585C7", +":) c #5088CC", +"<) c #4B8BD1", +"[) c #488DD3", +"}) c #3E90DB", +"|) c #8A5C88", +"1) c #885E8B", +"2) c #86608D", +"3) c #856290", +"4) c #836492", +"5) c #6D74AB", +"6) c #6B76AE", +"7) c #6679B3", +"8) c #5286C9", +"9) c #875E8B", +"0) c #855F8D", +"a) c #836290", +"b) c #826493", +"c) c #806595", +"d) c #7E6898", +"e) c #7271A7", +"f) c #6F73A9", +"g) c #6D75AC", +"h) c #6878B1", +"i) c #4D8ACE", +"j) c #4A8BD1", +"k) c #478DD4", +"l) c #448ED6", +"m) c #418FD9", +"n) c #3D91DB", +"o) c #826190", +"p) c #806393", +"q) c #7E6595", +"r) c #7C6798", +"s) c #7B699A", +"t) c #796A9D", +"u) c #647BB6", +"v) c #617CB8", +"w) c #4F88CC", +"x) c #4D8ACF", +"y) c #438ED6", +"z) c #408FD9", +"A) c #7D6595", +"B) c #79689A", +"C) c #776A9D", +"D) c #766C9F", +"E) c #746DA2", +"F) c #7071A7", +"G) c #6E73AA", +"H) c #6A76AE", +"I) c #617DB8", +"J) c #5C80BE", +"K) c #4C8ACF", +"L) c #498BD2", +"M) c #468DD4", +"N) c #438ED7", +"O) c #3F8FD9", +"P) c #3C91DB", +"Q) c #91567F", +"R) c #8F5882", +"S) c #816190", +"T) c #7D6596", +"U) c #78689B", +"V) c #76699D", +"W) c #746BA0", +"X) c #726CA2", +"Y) c #706FA4", +"Z) c #6E71A7", +"`) c #6D72AA", +" ! c #6B74AC", +".! c #6976AF", +"+! c #6777B1", +"@! c #637BB6", +"#! c #5E7EBB", +"$! c #5C7FBE", +"%! c #5A81C0", +"&! c #5584C5", +"*! c #5385C8", +"=! c #4D88CD", +"-! c #458CD4", +";! c #3C91DC", +">! c #8A5B87", +",! c #75699D", +"'! c #736BA0", +")! c #716DA2", +"!! c #6F6EA5", +"~! c #6C70A7", +"{! c #6B71AA", +"]! c #6973AC", +"^! c #6775AF", +"/! c #6577B1", +"(! c #617AB6", +"_! c #5D7EBB", +":! c #5B7FBE", +"<! c #5981C0", +"[! c #5682C3", +"}! c #5484C5", +"|! c #5185C8", +"1! c #4F87CA", +"2! c #4C88CD", +"3! c #3E90D9", +"4! c #8C5A84", +"5! c #7A6699", +"6! c #756A9D", +"7! c #6E6EA5", +"8! c #6C70A8", +"9! c #6972AA", +"0! c #6773AD", +"a! c #6575AF", +"b! c #6178B4", +"c! c #5F79B6", +"d! c #597EBE", +"e! c #5780C1", +"f! c #5482C3", +"g! c #5283C6", +"h! c #5085C8", +"i! c #4D86CA", +"j! c #4B88CD", +"k! c #428DD5", +"l! c #8A5C87", +"m! c #885D8A", +"n! c #855F8C", +"o! c #6276B2", +"p! c #6078B4", +"q! c #5E7AB7", +"r! c #5282C3", +"s! c #4E85C8", +"t! c #4C86CB", +"u! c #4988CD", +"v! c #4789D0", +"w! c #448BD2", +"x! c #3F8ED7", +". . . . . . + @ # $ % & * = - ; > , ' ) ! ~ { ] ^ / ( _ : < [ } | 1 2 3 4 5 6 7 8 9 0 a b c d e f g ", +". . . . . h i j k % l * = - m > n ' o ! p { q r s t u v < w } x y 2 z 4 5 6 7 8 A 0 B C c d e f D E ", +". . . . h F j k % G * H - m > n I J K p L M N s O P Q R S T U V W X 4 Y Z 7 ` A .B C c ..+.@.D E #.", +". . . $.F j k %.&.*.H =.m -.n ;.>.K ,.'.).!.~.{.].^.R /.(._.:.<.[.}.|.1.7 2.A 3.4.5.6...+.@.7.8.#.9.", +". . 0.F a.b.c.&.d.H e.f.-.g.h.>.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y.z.A.B.C.A 3.4.5.D...+.E.7.F.#.9.G.", +"H.0.I.a.J.c.&.K.L.e.f.-.g.M.N.i.O.k.P.Q.n.o.p.q.R.s.S.u.T.w.x.y.U.V.W.X.Y.Z.`.5.D... +.+++F.@+9.G.#+", +"0.$+%+&+c.&.K.L.*+=+-+;+M.N.>+O.,+'+Q.)+o.!+q.~+s.S.{+]+w.^+/+U.V.(+_+:+<+[+}+|+1+2+.+++F.3+9.4+#+5+", +"$+%+&+6+7+K.L.*+8+-+;+M.9+>+O.,+'+Q.)+0+!+q.~+s.S.{+]+a+b+/+U.c+d+_+:+e+f+g+h+i+j+.+++k+3+9.l+m+5+n+", +"o+&+p+7+q+r+s+8+, ;+M.t+u+O.v+'+w+x+0+y+q.~+z+A+B+]+C+D+/+E+F+d+G+:+H+f+g+I+J+K+L+M+N+O+P+l+m+Q+R+S+", +"&+& 7+T+r+s+8+, U+V+W+u+X+v+'+w+Y+Z+y+`+ @.@+@@@#@$@%@&@*@=@d+G+:+H+-@;@h+J+K+>@,@'@)@P+l+!@Q+R+S+~@", +"& 7+T+{@s+]@, ;+V+W+u+^@v+/@(@Y+Z+_@:@<@[@}@|@1@2@3@4@5@6@7@8@9@0@-@;@a@J+b@c@d@e@f@g@h@!@i@R+j@~@k@", +"l@T+{@m@> , n@V+W+o@p@v+q@(@r@s@t@u@v@w@x@y@z@A@B@C@D@E@F@G@H@I@J@K@L@J+b@c@d@e@M@N@O@P@Q@R+R@~@S@T@", +"T+{@; > , I U@V@o@p@v+q@(@r@W@X@Y@Z@`@ #.#+#@###$#%#&#*#=#-#;#>#,#'#)#b@c@d@!#M@N@~#{#]#^#/#~@(#T@_#", +"- m > , I U@:#<#p@).q@[#r@}#|#1#2#3#4#5#6#7#8#9#0#a#b#c#d#e#f#g#h#i#j#k#l#m#M@N@n#o#p#q#r#s#(#t#_#u#", +"m > n I J :#<#p@l.q@[#{.W@v#1#w#3#x#y#z#A#B#C#D#E#F#G#H#I#J#K#L#M#N#O#P#Q#R#S#n#o#p#q#T#U#V#W#_#u#X#", +"Y#n I J Z#<#k.l.q@n.{.W@v#`# $.$+$@$#$$$%$&$*$=$-$;$>$,$'$)$!$~${$]$^$/$($_$:${#<$q#[$}$|$1$2$u#3$4$", +"n 5$6$Z#,.k.l.7$n.8$p.9$`#w#0$+$a$b$c$d$e$f$g$h$i$j$,$k$l$m$n$o$p$q$r$s$t$u$v$<$w$x$}$y$z$A$B$C$4$D$", +"E$F$K ,.'.l.m.n.o.p.q.G$H$I$+$J$b$K$L$M$N$O$P$Q$R$S$T$U$V$W$X$Y$Z$`$ %.%+%@%#%$%x$}$y$z$%%&%*%=%D$-%", +"6$;%>%'.,%Q.)+o.p.q.'%)%!%~%J$#$c$L$M${%]%^%/%(%_%:%<%[%}%|%1%2%3%4%5%6%7%8%9%0%a%b%c%d%e%f%g%h%i%j%", +";%k%l%m%m.)+o.!+q.R.n%o%p%q%r%s%t%M${%u%v%w%x%y%z%A%B%C%D%E%F%G%H%I%J%K%L%M%N%O%P%c%d%Q%R%S%T%U%j%V%", +"k%W%X%m.)+0+!+q.~+Y%Z%`% &.&+&@&#&$&%&v%&&*&=&-&;&>&,&'&)&!&~&{&]&^&/&(&_&:&<&[&}&|&Q%1&S%2&3&4&5&6&", +"7&8&9&x+Z+y+0&~+z++@a&b&c&d&e&f&g&h&^%w%*&i&j&k&l&m&n&o&p&q&r&s&t&u&v&w&x&y&z&A&B&Q%C&S%2&D&E&F&G&H&", +"I&9&J&K&y+L&~+M&A+N&O&P&Q&R&S&T&U&V&W&X&Y&j&Z&`& *.*+*@*#*$*%*&***=*-*;*>*,*'*)*!*1&S%~*D&{*]*^*/*(*", +"/ _*K&:*L&~+M&<*B+[*2@}*|*1*2*3*4*5*6*y%7*k&`&8*9*0*a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*{*s*t*u*v*w*", +"( x*Q y*z*M&<*A*B*C*D*C@%#a#E*F*G*H*I*J*K*L* *9*M*N*O*P*Q*R*S*T*U*V*W*X*Y*Z*`* =.=~*r*{*+=@=#=$=%=&=", +"_ v *===-=;=A*B*>=,='=)=!=~={=]=^=/=(=_=:=<=.*0*N*[=}=|=1=2=3=4=5=6=7=8=9=0=a=b=c=d=e=f=@=g=h=i=j=k=", +": l=m=n=o=v.B*>=p=q=r=E@s=t=u=v=w=x=y=z=A=B=C=a*O*}=D=E=F=G=H=I=J=K=L=M=N=O=P=Q=R=S=f=T=g=U=V=W=X=Y=", +"< w (.Z=v.B*x.p=`= -.-+-@-#-I#w=$-%-&-*-=---;-b*P*>-E=,-'-)-!-~-{-]-^-/-(-_-:-<-[-f=}-|-U=1-2-3-4-5-", +"w 6-7-8-9-x.p=`=0-a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-1=q-'-r-s-t-u-v-w-x-y-z-A-B-C-D-E-|-F-1-G-H-I-J-K-", +"L-M-:.N-x.O-z.P-Q-R-S-T-U-V-W-X-Y-Z-`- ;.;+;@;#;$;2=%;)-&;*;=;-;;;>;,;';);!;~;{;];|-F-^;G-/;(;_;:;<;", +"M-[;};|;O-z.P-(+_+1;2;3;4;5;6;7;8;9;0;a;b;c;d;e;f;g;h;i;j;=;k;l;m;n;o;p;q;r;s;t;u;v;^;w;/;(;x;y;z;A;", +"B;C;D;E;z.V.(+_+1;e+F;G;H;I;J;K;L;M;N;O;P;Q;R;S;T;U;V;W;u-X;l;m;Y;Z;`; >.>+>@>#>v;^;w;/;$>%>&>*>=>->", +";>>>,>'>V.d+_+:+e+f+)>!>~>{>]>^>/>(>_>:><>[>}>|>1>2>3>4>5>6>7>8>9>`;0>a>b>c>d>e>f>w;/;g>%>h>i>j>k>l>", +">>,>m>n>W.G+:+e+f+g+I+o>p>q>r>s>t>u>v>w>x>y>z>A>6=B>C>D>E>F>G>H>I>J>a>K>L>M>N>O>w;P>Q>R>h>S>T>U>l>V>", +"W>X>Y>Z>`> ,H+-@;@I+J+.,+,@,#,$,%,&,*,=,-,;,>,,,7=',),!,~,{,],^,J>/,K>(,_,N>O>w;:,Q>R><,[,},|,1,V>2,", +"3,Y>8 4,5,6,-@;@I+J+b@c@7,8,9,0,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,J>p,q,(,r,s,t,u,:,Q>R>h>v,w,x,y,V>z,A,", +"Y>8 B,C,D,E,F,h+J+b@c@d@e@G,H,I,J,K,L,M,N,O,P,Y*Q,R,S,T,U,V,W,X,q,Y,r,s,t,u,:,Z,`, 'v,.'+'@'V>#'A,$'", +"8 B,0 a b %'&'J+*'c@d@e@M@N@='-';'>',''')'!'l*Z*~'{']'^'/'('_':'<'r,['t,u,}'Z,`, 'v,|'1'2'3'#'A,$'$'", +"9 0 a b 4'5'6'7'8'd@9'M@N@n#0'a'b'c'd'e'f'g'h'i'a=P=:-j'k'l'm'n'o'p'q'u,r's'`, 'v,|'t'u'v'#'A,$'$'$'", +"0 B C c d w'x'y'z'm#M@A'n#o#a'q#T#B'C'D'E'F'G' =H'Q=I'J'K'L'M'N'O'q'u,r's'P'Q'R'|'t'u'S'T'$'$'$'$'$'", +"B C c d e @.D U'V'W'S#X'o#p#q#T#}$|$Y'Z'`' ).)+)c=@)[-D-];#)U=$)G-%)&)*)P'=)R'-);)>)S'T'$'$'$'$'$'$'", +"5.c d +.@.7.8.#.,)')O@{#p#w$x$}$y$Y'%%))!)~){)])^)/)()E-g=F-1-G-/;&)_)P':)R'<)[)>)S'})$'$'$'$'$'$'$'", +"6...+.@.7.F.#.9.|)1)2)3)4)x$}$y$z$%%))R%~){)5)6)/)7)E-|-F-^;G-/;&)_)8):)R'<)[)>)S'})$'$'$'$'$'$'$'$'", +"..+..+++F.@+9.G.9)0)a)b)c)d)b%z$d%))R%e)f)g)6)h)7)E-|-v;^;w;/;$>_)8):)i)j)k)l)m)n)$'$'$'$'$'$'$'$'$'", +"+..+++F.3+9.4+#+5+o)p)q)r)s)t)A$&%R%S%f)g)6)h)7)u)v)v;^;w;/;$>%><,w)x)j)k)y)z)n)$'$'$'$'$'$'$'$'$'$'", +".+++k+3+9.l+#+5+o)S+A)k@B)C)D)E)*%F)G)g)H)h)7)u)I)v;J)w;/;Q>%>h>w)K)L)M)N)O)P)$'$'$'$'$'$'$'$'$'$'$'", +"Q)R)O+P+l+#+5+S)S+T)k@U)V)W)X)Y)Z)`) !.!+!t*@!v)#!$!%!:,&!*!&>=!},x,-!3'O);!$'$'$'$'$'$'$'$'$'$'$'$'", +"R)O+>!l+m+Q+R+S+~@k@U),!'!)!!!~!{!]!^!/!^*(!$=_!:!<![!}!|!1!2!j>U>1,3'3!;!$'$'$'$'$'$'$'$'$'$'$'$'$'", +"4!>!l+!@Q+R+j@~@5!U)6!'!)!7!8!9!0!a!V%b!c!v*%=d!e!f!g!h!i!j!=>k>k!V>#'A,$'$'$'$'$'$'$'$'$'$'$'$'$'$'", +"l!m!n!Q+R+R@~@S@T@_#'!X#7!8!9!0!a!o!p!q!(*w*&=k=r!5-s!t!u!v!w!k!x!#'A,$'$'$'$'$'$'$'$'$'$'$'$'$'$'$'"}; diff --git a/ext/gd/tests/copy.phpt b/ext/gd/tests/copy.phpt new file mode 100644 index 0000000..5aafc31 --- /dev/null +++ b/ext/gd/tests/copy.phpt @@ -0,0 +1,109 @@ +--TEST-- +imagecopy +--SKIPIF-- +<?php + if (!function_exists('imagecopy')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php + +$src_tc = imagecreatetruecolor(5,5); +imagefill($src_tc, 0,0, 0xffffff); +imagesetpixel($src_tc, 3,3, 0xff0000); +imagesetpixel($src_tc, 0,0, 0x0000ff); +imagesetpixel($src_tc, 4,4, 0x00ff00); + + +$dst_tc = imagecreatetruecolor(5,5); +imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc)); +$p1 = imagecolorat($dst_tc, 3,3) == 0xff0000; +$p2 = imagecolorat($dst_tc, 0,0) == 0x0000ff; +$p3 = imagecolorat($dst_tc, 4,4) == 0x00ff00; + +if ($p1 && $p2 && $p3) { + echo "TC/TC: ok\n"; +} + +imagedestroy($src_tc); imagedestroy($dst_tc); + + +$src_tc = imagecreatetruecolor(5,5); +imagefill($src_tc, 0,0, 0xffffff); +imagesetpixel($src_tc, 3,3, 0xff0000); +imagesetpixel($src_tc, 0,0, 0x0000ff); +imagesetpixel($src_tc, 4,4, 0x00ff00); + + +$dst_tc = imagecreate(5,5); +imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc)); + +$c1 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 3,3)); +$c2 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 0,0)); +$c3 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 4,4)); + +$p1 = $c1['red'] == 0xff && $c1['blue']==0x00 && $c1['green']==0x00; +$p2 = $c2['red'] == 0x00 && $c2['blue']==0xff && $c2['green']==0x00; +$p3 = $c3['red'] == 0x00 && $c3['blue']==0x00 && $c3['green']==0xff; + +if ($p1 && $p2 && $p3) { + echo "TC/P: ok\n"; +} +imagedestroy($src_tc); imagedestroy($dst_tc); + + + +$src_tc = imagecreate(5,5); +$c0 = imagecolorallocate($src_tc, 0xff, 0xff, 0xff); +$c1 = imagecolorallocate($src_tc, 0xff, 0x00, 0x00); +$c2 = imagecolorallocate($src_tc, 0x00, 0x00, 0xff); +$c3 = imagecolorallocate($src_tc, 0x00, 0xff, 0x00); + +imagesetpixel($src_tc, 3,3, $c1); +imagesetpixel($src_tc, 0,0, $c2); +imagesetpixel($src_tc, 4,4, $c3); + + +$dst_tc = imagecreate(5,5); +imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc)); + +$c1 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 3,3)); +$c2 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 0,0)); +$c3 = imagecolorsforindex($dst_tc, imagecolorat($dst_tc, 4,4)); + +$p1 = $c1['red'] == 0xff && $c1['blue']==0x00 && $c1['green']==0x00; +$p2 = $c2['red'] == 0x00 && $c2['blue']==0xff && $c2['green']==0x00; +$p3 = $c3['red'] == 0x00 && $c3['blue']==0x00 && $c3['green']==0xff; + + +if ($p1 && $p2 && $p3) { + echo "P/P: ok\n"; +} + + + +$src_tc = imagecreate(5,5); +$c0 = imagecolorallocate($src_tc, 0xff, 0xff, 0xff); +$c1 = imagecolorallocate($src_tc, 0xff, 0x00, 0x00); +$c2 = imagecolorallocate($src_tc, 0x00, 0x00, 0xff); +$c3 = imagecolorallocate($src_tc, 0x00, 0xff, 0x00); + +imagesetpixel($src_tc, 3,3, $c1); +imagesetpixel($src_tc, 0,0, $c2); +imagesetpixel($src_tc, 4,4, $c3); + + +$dst_tc = imagecreatetruecolor(5,5); +imagecopy($dst_tc, $src_tc, 0,0, 0,0, imagesx($src_tc), imagesy($src_tc)); +$p1 = imagecolorat($dst_tc, 3,3) == 0xff0000; +$p2 = imagecolorat($dst_tc, 0,0) == 0x0000ff; +$p3 = imagecolorat($dst_tc, 4,4) == 0x00ff00; + +if ($p1 && $p2 && $p3) { + echo "P/TC: ok\n"; +} +?> +--EXPECTF-- +TC/TC: ok +TC/P: ok +P/P: ok +P/TC: ok diff --git a/ext/gd/tests/copypalette.phpt b/ext/gd/tests/copypalette.phpt new file mode 100644 index 0000000..ec00c03 --- /dev/null +++ b/ext/gd/tests/copypalette.phpt @@ -0,0 +1,44 @@ +--TEST-- +imagepalettecopy +--SKIPIF-- +<?php + if (!function_exists('imagecolorat')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$failed = false; +$im = imagecreate(1,1); +for ($i=0; $i<256; $i++) { + imagecolorallocate($im, $i, $i, $i); +} + +$im2 = imagecreate(1,1); +imagepalettecopy($im2, $im); + +for ($i=0; $i<256; $i++) { + $c = imagecolorsforindex($im2, $i); + if ($c['red']!=$i || $c['green']!=$i || $c['blue']!=$i) { + $failed = true; + break; + } +} +echo "copy palette 255 colors: "; +echo $failed ? 'failed' : 'ok'; +echo "\n"; + +$im = imagecreate(1,1); +$im2 = imagecreate(1,1); +imagecolorallocatealpha($im, 0,0,0,100); + +imagepalettecopy($im2, $im); +$c = imagecolorsforindex($im2, 0); +if ($c['red']!=0 || $c['green']!=0 || $c['blue']!=0 || $c['alpha']!=100) { + $failed = true; +} +echo 'copy palette 1 color and alpha: '; +echo $failed ? 'failed' : 'ok'; +echo "\n"; +?> +--EXPECT-- +copy palette 255 colors: ok +copy palette 1 color and alpha: ok diff --git a/ext/gd/tests/copyresized.phpt b/ext/gd/tests/copyresized.phpt new file mode 100644 index 0000000..fe98642 --- /dev/null +++ b/ext/gd/tests/copyresized.phpt @@ -0,0 +1,91 @@ +--TEST-- +imagecopyresized +--SKIPIF-- +<?php + if (!function_exists('imagecopyresized')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php + +function get_hexcolor($im, $c) { + if (imageistruecolor($im)) { + return $c; + } + $colors = imagecolorsforindex($im, $c); + return ($colors['red'] << 16) + ($colors['green'] << 8) + ($colors['blue']); +} + +function check_doublesize($dst) { + $im = imagecreatetruecolor(38,38); + imagefill($im,0,0, 0xffffff); + imagefilledrectangle($im, 0,0,9,9, 0xff0000); + imagefilledrectangle($im, 0,28,9,37, 0xff0000); + imagefilledrectangle($im, 28,0,37,9, 0xff0000); + imagefilledrectangle($im, 28,28,37,37, 0xff0000); + imagefilledrectangle($im, 14,14,23,23, 0xff0000); + + for ($x = 0; $x < 38; $x++) { + for ($y = 0; $y < 38; $y++) { + $p1 = imagecolorat($im, $x, $y); + $p2 = imagecolorat($dst, $x, $y); + if (get_hexcolor($im, $p1) != get_hexcolor($dst, $p2)) { + return false; + } + } + } + return true; +} + +$src_tc = imagecreatetruecolor(19,19); +imagefill($src_tc, 0,0, 0xffffff); +imagefilledrectangle($src_tc, 0,0,4,4, 0xff0000); +imagefilledrectangle($src_tc, 14,0,18,4, 0xff0000); +imagefilledrectangle($src_tc, 0,14,4,18, 0xff0000); +imagefilledrectangle($src_tc, 14,14,18,18, 0xff0000); +imagefilledrectangle($src_tc, 7,7,11,11, 0xff0000); + +$dst_tc = imagecreatetruecolor(38,38); +imagecopyresized($dst_tc, $src_tc, 0,0, 0,0, imagesx($dst_tc), imagesy($dst_tc), 19,19); + +if (!check_doublesize($dst_tc)) exit("1 failed\n"); +echo "TC->TC: ok\n"; + +$src_tc = imagecreate(19,19); +$white = imagecolorallocate($src_tc, 255,255,255); +$red = imagecolorallocate($src_tc, 255,0,0); + +imagefilledrectangle($src_tc, 0,0,4,4, $red); +imagefilledrectangle($src_tc, 14,0,18,4, $red); +imagefilledrectangle($src_tc, 0,14,4,18, $red); +imagefilledrectangle($src_tc, 14,14,18,18, $red); +imagefilledrectangle($src_tc, 7,7,11,11, $red); + +$dst_tc = imagecreatetruecolor(38,38); +imagecopyresized($dst_tc, $src_tc, 0,0, 0,0, imagesx($dst_tc), imagesy($dst_tc), 19,19); + +if (!check_doublesize($dst_tc)) exit("2 failed\n"); +echo "P->TC: ok\n"; + +$src_tc = imagecreate(19,19); +$white = imagecolorallocate($src_tc, 255,255,255); +$red = imagecolorallocate($src_tc, 255,0,0); + +imagefilledrectangle($src_tc, 0,0,4,4, $red); +imagefilledrectangle($src_tc, 14,0,18,4, $red); +imagefilledrectangle($src_tc, 0,14,4,18, $red); +imagefilledrectangle($src_tc, 14,14,18,18, $red); +imagefilledrectangle($src_tc, 7,7,11,11, $red); + +$dst_tc = imagecreate(38,38); +$white = imagecolorallocate($src_tc, 255,255,255); +$red = imagecolorallocate($src_tc, 255,0,0); + +imagecopyresized($dst_tc, $src_tc, 0,0, 0,0, imagesx($dst_tc), imagesy($dst_tc), 19,19); + +if (!check_doublesize($dst_tc)) exit("3 failed\n"); +echo "P->P: ok\n"; +?> +--EXPECTF-- +TC->TC: ok +P->TC: ok +P->P: ok diff --git a/ext/gd/tests/crafted.gd2 b/ext/gd/tests/crafted.gd2 Binary files differnew file mode 100644 index 0000000..45c944c --- /dev/null +++ b/ext/gd/tests/crafted.gd2 diff --git a/ext/gd/tests/crafted_gd2.phpt b/ext/gd/tests/crafted_gd2.phpt new file mode 100644 index 0000000..7bcbc4e --- /dev/null +++ b/ext/gd/tests/crafted_gd2.phpt @@ -0,0 +1,16 @@ +--TEST-- +Test max colors for a gd image. +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available\n"); + } +?> +--FILE-- +<?php +imagecreatefromgd(dirname(__FILE__) . '/crafted.gd2'); +?> +--EXPECTF-- + +Warning: imagecreatefromgd(): '%scrafted.gd2' is not a valid GD file in %s on line %d + diff --git a/ext/gd/tests/createfromgd2.phpt b/ext/gd/tests/createfromgd2.phpt new file mode 100644 index 0000000..e43d1b8 --- /dev/null +++ b/ext/gd/tests/createfromgd2.phpt @@ -0,0 +1,23 @@ +--TEST-- +imagecreatefromgd2 +--SKIPIF-- +<?php + if (!function_exists('imagecreatefromgd2')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$file = dirname(__FILE__) . '/src.gd2'; + +$im2 = imagecreatefromgd2($file); +echo 'test create from gd2: '; +echo imagecolorat($im2, 4,4) == 0xffffff ? 'ok' : 'failed'; +echo "\n"; + +$im3 = imagecreatefromgd2part($file, 4,4, 2,2); +echo 'test create from gd2 part: '; +echo imagecolorat($im2, 4,4) == 0xffffff ? 'ok' : 'failed'; +echo "\n"; +?> +--EXPECT-- +test create from gd2: ok +test create from gd2 part: ok diff --git a/ext/gd/tests/createfromstring.phpt b/ext/gd/tests/createfromstring.phpt new file mode 100644 index 0000000..a3c2e97 --- /dev/null +++ b/ext/gd/tests/createfromstring.phpt @@ -0,0 +1,64 @@ +--TEST-- +imagecreatefromstring +--SKIPIF-- +<?php + if (!function_exists('imagecreatefromstring')) die("skip gd extension not available\n"); + if (!function_exists('imagepng')) die("skip no imagpng()\n"); +?> +--FILE-- +<?php +$dir = dirname(__FILE__); + +$im = imagecreatetruecolor(5,5); +imagefill($im, 0,0, 0xffffff); +imagesetpixel($im, 3,3, 0x0); +imagepng($im, $dir . '/tc.png'); + +$im_string = file_get_contents(dirname(__FILE__) . '/tc.png'); +$im = imagecreatefromstring($im_string); +echo 'createfromstring truecolor png: '; +if (imagecolorat($im, 3,3) != 0x0) { + echo 'failed'; +} else { + echo 'ok'; +} +echo "\n"; +unlink($dir . '/tc.png'); + + + +$im = imagecreate(5,5); +$c1 = imagecolorallocate($im, 255,255,255); +$c2 = imagecolorallocate($im, 255,0,0); +imagefill($im, 0,0, $c1); +imagesetpixel($im, 3,3, $c2); +imagepng($im, $dir . '/p.png'); + +$im_string = file_get_contents(dirname(__FILE__) . '/p.png'); +$im = imagecreatefromstring($im_string); + +echo'createfromstring palette png: '; + +$c = imagecolorsforindex($im, imagecolorat($im, 3,3)); +$failed = false; +if ($c['red'] != 255 || $c['green'] != 0 || $c['blue'] != 0) { + echo 'failed'; +} else { + echo 'ok'; +} +echo "\n"; +unlink($dir . '/p.png'); + + +//empty string +$im = imagecreatefromstring(''); +//random string > 8 +$im = imagecreatefromstring(' asdf jklp'); +?> +--EXPECTF-- +createfromstring truecolor png: ok +createfromstring palette png: ok + +Warning: imagecreatefromstring(): Empty string or invalid image in %screatefromstring.php on line %d + +Warning: imagecreatefromstring(): Data is not in a recognized format in %screatefromstring.php on line %d diff --git a/ext/gd/tests/createfromwbmp.phpt b/ext/gd/tests/createfromwbmp.phpt new file mode 100644 index 0000000..589bbaf --- /dev/null +++ b/ext/gd/tests/createfromwbmp.phpt @@ -0,0 +1,17 @@ +--TEST-- +imagecreatefromwbmp +--SKIPIF-- +<?php + if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$file = dirname(__FILE__) . '/src.wbmp'; + +$im2 = imagecreatefromwbmp($file); +echo 'test create from wbmp: '; +echo imagecolorat($im2, 3,3) == 0x0 ? 'ok' : 'failed'; +echo "\n"; +?> +--EXPECT-- +test create from wbmp: ok diff --git a/ext/gd/tests/createfromwbmp2.phpt b/ext/gd/tests/createfromwbmp2.phpt new file mode 100644 index 0000000..9e7ef12 --- /dev/null +++ b/ext/gd/tests/createfromwbmp2.phpt @@ -0,0 +1,48 @@ +--TEST-- +imagecreatefromwbmp with invalid wbmp +--SKIPIF-- +<?php + if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php +$filename = dirname(__FILE__) . '/_tmp.wbmp'; +$fp = fopen($filename,"wb"); +if (!$fp) { + exit("Failed to create <$filename>"); +} + +//write header +$c = 0; +fputs($fp, chr($c), 1); +fputs($fp, $c, 1); + +//write width = 2^32 / 4 + 1 +$c = 0x84; +fputs($fp, chr($c), 1); +$c = 0x80; +fputs($fp, chr($c), 1); +fputs($fp, chr($c), 1); +fputs($fp, chr($c), 1); +$c = 0x01; +fputs($fp, chr($c), 1); + +/*write height = 4*/ +$c = 0x04; +fputs($fp, chr($c), 1); + +/*write some data to cause overflow*/ +for ($i=0; $i<10000; $i++) { + fwrite($fp, chr($c), 1); +} + +fclose($fp); +$im = imagecreatefromwbmp($filename); +unlink($filename); +?> +--EXPECTF-- +Warning: imagecreatefromwbmp(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully + in %s on line %d + +Warning: imagecreatefromwbmp(): '%s' is not a valid WBMP file in %s on line %d diff --git a/ext/gd/tests/createfromwbmp2_extern.phpt b/ext/gd/tests/createfromwbmp2_extern.phpt new file mode 100644 index 0000000..7be46f7 --- /dev/null +++ b/ext/gd/tests/createfromwbmp2_extern.phpt @@ -0,0 +1,47 @@ +--TEST-- +imagecreatefromwbmp with invalid wbmp +--SKIPIF-- +<?php + if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n"); + if (GD_BUNDLED) die("skip requires extern GD\n"); +?> +--FILE-- +<?php +$filename = dirname(__FILE__) . '/_tmp.wbmp'; +$fp = fopen($filename,"wb"); +if (!$fp) { + exit("Failed to create <$filename>"); +} + +//write header +$c = 0; +fputs($fp, chr($c), 1); +fputs($fp, $c, 1); + +//write width = 2^32 / 4 + 1 +$c = 0x84; +fputs($fp, chr($c), 1); +$c = 0x80; +fputs($fp, chr($c), 1); +fputs($fp, chr($c), 1); +fputs($fp, chr($c), 1); +$c = 0x01; +fputs($fp, chr($c), 1); + +/*write height = 4*/ +$c = 0x04; +fputs($fp, chr($c), 1); + +/*write some data to cause overflow*/ +for ($i=0; $i<10000; $i++) { + fwrite($fp, chr($c), 1); +} + +fclose($fp); +$im = imagecreatefromwbmp($filename); +unlink($filename); +?> +--EXPECTF-- +gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully + +Warning: imagecreatefromwbmp(): '%s_tmp.wbmp' is not a valid WBMP file in %s on line %d diff --git a/ext/gd/tests/dashedlines.phpt b/ext/gd/tests/dashedlines.phpt new file mode 100644 index 0000000..7c13084 --- /dev/null +++ b/ext/gd/tests/dashedlines.phpt @@ -0,0 +1,78 @@ +--TEST-- +imageline, dashed +--SKIPIF-- +<?php + if (!function_exists('imagecreatefromstring')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); + +$r = 0xff0000; +$b = 0x0000ff; + +$style = array($r, $b); +imagesetstyle($im, $style); + +// Horizontal line +imageline($im, 0,5, 5,5, IMG_COLOR_STYLED); +$p1 = imagecolorat($im, 0,5) == $r; +$p2 = imagecolorat($im, 1,5) == $b; +$p3 = imagecolorat($im, 2,5) == $r; +$p4 = imagecolorat($im, 3,5) == $b; +$p5 = imagecolorat($im, 4,5) == $r; +$p5 = imagecolorat($im, 5,5) == $b; + + +if ($p1 && $p2 && $p3 && $p4 && $p5) { + echo "Horizontal: ok\n"; +} +imagedestroy($im); + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); + +$style = array($r, $b); +imagesetstyle($im, $style); + + +imageline($im, 2,0, 2,5, IMG_COLOR_STYLED); +$p1 = imagecolorat($im, 2,0) == $r; +$p2 = imagecolorat($im, 2,1) == $b; +$p3 = imagecolorat($im, 2,2) == $r; +$p4 = imagecolorat($im, 2,3) == $b; +$p5 = imagecolorat($im, 2,4) == $r; +$p6 = imagecolorat($im, 2,5) == $b; + +if ($p1 && $p2 && $p3 && $p4 && $p5 && $p6) { + echo "Vertical: ok\n"; +} +imagedestroy($im); + + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); + +$style = array($r, $b); +imagesetstyle($im, $style); + +imageline($im, 0,0, 5,5, IMG_COLOR_STYLED); +$p1 = imagecolorat($im, 0,0) == $r; +$p2 = imagecolorat($im, 1,1) == $b; +$p3 = imagecolorat($im, 2,2) == $r; +$p4 = imagecolorat($im, 3,3) == $b; +$p5 = imagecolorat($im, 4,4) == $r; +$p6 = imagecolorat($im, 5,5) == $b; + +if ($p1 && $p2 && $p3 && $p4 && $p5 && $p6) { + echo "Diagonal: ok\n"; +} +imagedestroy($im); + + +?> +--EXPECTF-- +Horizontal: ok +Vertical: ok +Diagonal: ok diff --git a/ext/gd/tests/func.inc b/ext/gd/tests/func.inc new file mode 100644 index 0000000..f17227e --- /dev/null +++ b/ext/gd/tests/func.inc @@ -0,0 +1,61 @@ +<?php
+
+function get_gd_version()
+{
+ return GD_VERSION;
+}
+
+function get_php_info()
+{
+ ob_start();
+ phpinfo();
+ $info = ob_get_contents();
+ ob_end_clean();
+
+ return $info;
+}
+
+function get_freetype_version()
+{
+ $version = 0;
+
+ if (preg_match(',FreeType Version => (\d+\.\d+\.\d+),s', get_php_info(), $match)) {
+ $version = $match[1];
+ }
+
+ return $version;
+}
+
+function get_libjpeg_version()
+{
+ $version = 0;
+
+ if (preg_match(',libJPEG Version => ([a-z0-9]+),s', get_php_info(), $match)) {
+ $version = $match[1];
+ }
+
+ return $version;
+}
+
+function get_libpng_version()
+{
+ $version = 0;
+
+ if (preg_match(',libPNG Version => (\d+\.\d+\.\d+),s', get_php_info(), $match)) {
+ $version = $match[1];
+ }
+
+ return $version;
+}
+
+function get_libxpm_version()
+{
+ $version = 0;
+
+ if (preg_match(',libXpm Version => (\d+),s', get_php_info(), $match)) {
+ $version = $match[1];
+ }
+
+ return $version;
+}
+
diff --git a/ext/gd/tests/gd_info_basic.phpt b/ext/gd/tests/gd_info_basic.phpt new file mode 100644 index 0000000..61a2304 --- /dev/null +++ b/ext/gd/tests/gd_info_basic.phpt @@ -0,0 +1,29 @@ +--TEST-- +gd_info() +--SKIPIF-- +<?php + if (!function_exists('gd_info')) { + die('skip gd_info() not available'); + } +?> +--FILE-- +<?php + +/* Prototype : array gd_info ( void ) + * Description: Retrieve information about the currently installed GD library + * Source code: ext/standard/image.c + * Alias to functions: + */ + echo "basic test of gd_info() function\n"; + + var_dump(gd_info()); + + echo "\nDone\n"; +?> +--EXPECTF-- +basic test of gd_info() function +array(%d) { +%a +} + +Done diff --git a/ext/gd/tests/gd_info_error.phpt b/ext/gd/tests/gd_info_error.phpt new file mode 100644 index 0000000..15a26e4 --- /dev/null +++ b/ext/gd/tests/gd_info_error.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test gd_info() function : error conditions - with more than expected number of arguments +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('gd_info')) { + die('skip gd_info function is not available'); +} +?> +--FILE-- +<?php +/* Prototype : array gd_info() + * Description: Retrieve information about the currently installed GD library + * Source code: ext/gd/gd.c + */ +$extra_arg_number = 10; +$extra_arg_string = "Hello"; + +echo "*** Testing gd_info() : error conditions ***\n"; + +echo "\n-- Testing gd_info() function with more than expected number of arguments --\n"; +var_dump(gd_info($extra_arg_number)); +var_dump(gd_info($extra_arg_string, $extra_arg_number)); +?> +===DONE=== +--EXPECTF-- +*** Testing gd_info() : error conditions *** + +-- Testing gd_info() function with more than expected number of arguments -- + +Warning: gd_info() expects exactly 0 parameters, 1 given in %s on line %d +bool(false) + +Warning: gd_info() expects exactly 0 parameters, 2 given in %s on line %d +bool(false) +===DONE===
\ No newline at end of file diff --git a/ext/gd/tests/gd_info_variation1.phpt b/ext/gd/tests/gd_info_variation1.phpt new file mode 100644 index 0000000..a725f65 --- /dev/null +++ b/ext/gd/tests/gd_info_variation1.phpt @@ -0,0 +1,50 @@ +--TEST-- +Test gd_info() function : variation - Checking all the values in returned array +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('gd_info')) { + die('skip gd_info function is not available'); +} +?> +--FILE-- +<?php +/* Prototype : array gd_info() + * Description: Retrieve information about the currently installed GD library + * Source code: ext/gd/gd.c + */ + +echo "*** Testing gd_info() : variation ***\n"; + +var_dump(gd_info()); +?> +===DONE=== +--EXPECTF-- +*** Testing gd_info() : variation *** +array(%d) { + ["GD Version"]=> + string(%d) %a + ["FreeType Support"]=> + bool%a + ["T1Lib Support"]=> + bool%a + ["GIF Read Support"]=> + bool%a + ["GIF Create Support"]=> + bool%a + ["JPEG Support"]=> + bool%a + ["PNG Support"]=> + bool%a + ["WBMP Support"]=> + bool%a + ["XPM Support"]=> + bool%a + ["XBM Support"]=> + bool%a + ["JIS-mapped Japanese Font Support"]=> + bool%a +} +===DONE===
\ No newline at end of file diff --git a/ext/gd/tests/gif.phpt b/ext/gd/tests/gif.phpt new file mode 100644 index 0000000..eab8f5f --- /dev/null +++ b/ext/gd/tests/gif.phpt @@ -0,0 +1,146 @@ +--TEST-- +gif in/out +--SKIPIF-- +<?php +// $Id$ + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + if (!function_exists("imagegif") || !function_exists("imagecreatefromgif") || !function_exists('imagecreatefromjpeg')) { + die("skip gif support unavailable"); + } +?> +--FILE-- +<?php + +function check_box($r,$g,$b, $error=0) { + $cwd = dirname(__FILE__); + $im2 = imagecreatefromgif($cwd . '/test_gif.gif'); + + $c = imagecolorsforindex($im2, imagecolorat($im2, 8,8)); + + if ($error>0) { + $r_min = $r - $error; $r_max = $r + $error; + $g_min = $g - $error; $g_max = $g + $error; + $b_min = $b - $error; $b_max = $b + $error; + + if ( + ($c['red'] >= $r_min || $c['red'] <= $r_max) + && + ($c['green'] >= $g_min || $c['green'] <= $g_max) + && + ($c['blue'] >= $b_min || $c['blue'] <= $b_max) + ) { + return true; + } else { + return false; + } + } else { + if ($c['red']==$r && $c['green']==$g && $c['blue']==$b) { + return true; + } else { + return false; + } + } +} +$cwd = dirname(__FILE__); + +$im = imagecreate(10,10); +$c = imagecolorallocate($im, 255,255,255); +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +if (check_box(255,255,255)) { + echo "<4 cols: ok\n"; +} + +$im = imagecreate(10,10); +for ($i=0; $i<7; $i++) { + $c = imagecolorallocate($im, $i,$i,$i); +} +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +$i--; +if (check_box($i,$i,$i)) { + echo "<8 cols: ok\n"; +} + + +$im = imagecreate(10,10); +for ($i=0; $i<15; $i++) { + $c = imagecolorallocate($im, $i,$i,$i); +} +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +$i--; +if (check_box($i,$i,$i)) { + echo "<16 cols: ok\n"; +} + + +$im = imagecreate(10,10); +for ($i=0; $i<31; $i++) { + $c = imagecolorallocate($im, $i,$i,$i); +} +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +$i--; +if (check_box($i,$i,$i)) { + echo "<32 cols: ok\n"; +} + + +$im = imagecreate(10,10); +for ($i=0; $i<63; $i++) { + $c = imagecolorallocate($im, $i,$i,$i); +} +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +$i--; +if (check_box($i,$i,$i)) { + echo "<64 cols: ok\n"; +} + +$im = imagecreate(10,10); +for ($i=0; $i<127; $i++) { + $c = imagecolorallocate($im, $i,$i,$i); +} +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +$i--; +if (check_box($i,$i,$i)) { + echo "<128 cols: ok\n"; +} + +$im = imagecreate(10,10); +for ($i=0; $i<255; $i++) { + $c = imagecolorallocate($im, $i,$i,$i); +} +imagefilledrectangle($im, 5,5, 10,10, $c); +imagegif($im, $cwd . '/test_gif.gif'); +$i--; +if (check_box($i,$i,$i)) { + echo "<256 cols: ok\n"; +} + + +$im = imagecreatefromjpeg($cwd . '/conv_test.jpeg'); +imagefilledrectangle($im, 5,5, 10,10, 0xffffff); +imagegif($im, $cwd . '/test_gif.gif'); +imagegif($im, $cwd . '/test_gif_2.gif'); + +if (check_box(255,255,255, 10)) { + echo ">256 cols: ok\n"; +} + +@unlink($cwd . "/test_gif.gif"); +@unlink($cwd . "/test_gif_2.gif"); +?> +--EXPECT-- +<4 cols: ok +<8 cols: ok +<16 cols: ok +<32 cols: ok +<64 cols: ok +<128 cols: ok +<256 cols: ok +>256 cols: ok diff --git a/ext/gd/tests/gif2gd.phpt b/ext/gd/tests/gif2gd.phpt new file mode 100644 index 0000000..17ec158 --- /dev/null +++ b/ext/gd/tests/gif2gd.phpt @@ -0,0 +1,30 @@ +--TEST-- +gif --> gd1/gd2 conversion test +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + + if (!function_exists("imagecreatefromgif")) { + die("skip gif read support unavailable"); + } +?> +--FILE-- +<?php + $cwd = dirname(__FILE__); + + echo "GIF to GD1 conversion: "; + echo imagegd(imagecreatefromgif($cwd . "/conv_test.gif"), $cwd . "/test.gd1") ? 'ok' : 'failed'; + echo "\n"; + + echo "GIF to GD2 conversion: "; + echo imagegd2(imagecreatefromgif($cwd . "/conv_test.gif"), $cwd . "/test.gd2") ? 'ok' : 'failed'; + echo "\n"; + + @unlink($cwd . "/test.gd1"); + @unlink($cwd . "/test.gd2"); +?> +--EXPECT-- +GIF to GD1 conversion: ok +GIF to GD2 conversion: ok diff --git a/ext/gd/tests/gif2jpg.phpt b/ext/gd/tests/gif2jpg.phpt new file mode 100644 index 0000000..5f32c35 --- /dev/null +++ b/ext/gd/tests/gif2jpg.phpt @@ -0,0 +1,27 @@ +--TEST-- +gif --> jpeg conversion test +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + + if (!function_exists("imagejpeg")) { + die("skip jpeg support unavailable"); + } + if (!function_exists("imagecreatefromgif")) { + die("skip gif read support unavailable"); + } +?> +--FILE-- +<?php + $cwd = dirname(__FILE__); + + echo "GIF to JPEG conversion: "; + echo imagejpeg(imagecreatefromgif($cwd . "/conv_test.gif"), $cwd . "/test_gif.jpeg") ? 'ok' : 'failed'; + echo "\n"; + + @unlink($cwd . "/test_gif.jpeg"); +?> +--EXPECT-- +GIF to JPEG conversion: ok diff --git a/ext/gd/tests/gif2png.phpt b/ext/gd/tests/gif2png.phpt new file mode 100644 index 0000000..3b8beca --- /dev/null +++ b/ext/gd/tests/gif2png.phpt @@ -0,0 +1,27 @@ +--TEST-- +gif --> png conversion test +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + + if (!function_exists("imagepng")) { + die("skip png support unavailable"); + } + if (!function_exists("imagecreatefromgif")) { + die("skip gif read support unavailable"); + } +?> +--FILE-- +<?php + $cwd = dirname(__FILE__); + + echo "GIF to PNG conversion: "; + echo imagepng(imagecreatefromgif($cwd . "/conv_test.gif"), $cwd . "/test_gif.png") ? 'ok' : 'failed'; + echo "\n"; + + @unlink($cwd . "/test_gif.png"); +?> +--EXPECT-- +GIF to PNG conversion: ok diff --git a/ext/gd/tests/imageantialias_error1.phpt b/ext/gd/tests/imageantialias_error1.phpt new file mode 100644 index 0000000..e9475e9 --- /dev/null +++ b/ext/gd/tests/imageantialias_error1.phpt @@ -0,0 +1,19 @@ +--TEST-- +Testing wrong parameter resource in imageantialias() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +if (!GD_BUNDLED) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php +$image = tmpfile(); + +var_dump(imageantialias($image, true)); +?> +--EXPECTF-- +Warning: imageantialias(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imageantialias_error2.phpt b/ext/gd/tests/imageantialias_error2.phpt new file mode 100644 index 0000000..64b0a60 --- /dev/null +++ b/ext/gd/tests/imageantialias_error2.phpt @@ -0,0 +1,24 @@ +--TEST-- +Testing wrong parameter passing in imageantialias() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +if (!GD_BUNDLED) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php +/* + +It seems the second argument passing is not being correclty checked. +This test is failing due to this wrogn check + +*/ +$image = imagecreatetruecolor(180, 30); + +var_dump(imageantialias($image, 'wrong param')); // 'wrogn param' is converted to true +?> +--EXPECTF-- +bool(true) diff --git a/ext/gd/tests/imagearc_basic.phpt b/ext/gd/tests/imagearc_basic.phpt new file mode 100644 index 0000000..4647dd1 --- /dev/null +++ b/ext/gd/tests/imagearc_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +Testing imagearc() of GD library +--CREDITS-- +Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(100, 100); + +$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); + +//create an arc with white color +imagearc($image, 50, 50, 30, 30, 0, 180, $white); + +ob_start(); +imagepng($image); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +f18ad8001afefee2e9b8c08d6884425b diff --git a/ext/gd/tests/imagearc_error1.phpt b/ext/gd/tests/imagearc_error1.phpt new file mode 100644 index 0000000..423f035 --- /dev/null +++ b/ext/gd/tests/imagearc_error1.phpt @@ -0,0 +1,29 @@ +--TEST-- +Testing wrong param passing imagearc() of GD library +--CREDITS-- +Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(100, 100); + +$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); + +//create an arc with white color +imagearc($image, 50, 50, 30, 30, 0, 180); + +ob_start(); +imagepng($image); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECTF-- +Warning: imagearc() expects exactly 8 parameters, 7 given in %s on line %d +abebb25b5a2813cfbf92f1f24365786a diff --git a/ext/gd/tests/imagearc_variation1.phpt b/ext/gd/tests/imagearc_variation1.phpt new file mode 100644 index 0000000..568d3a6 --- /dev/null +++ b/ext/gd/tests/imagearc_variation1.phpt @@ -0,0 +1,28 @@ +--TEST-- +Testing passing negative end angle to imagearc() of GD library +--CREDITS-- +Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(100, 100); + +$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); + +//create an arc with white color +imagearc($image, 50, 50, 30, 30, 0, -90, $white); + +ob_start(); +imagepng($image); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +ed2c8427a9922dfd8a105f10a88a0d20 diff --git a/ext/gd/tests/imagearc_variation2.phpt b/ext/gd/tests/imagearc_variation2.phpt new file mode 100644 index 0000000..045c68e --- /dev/null +++ b/ext/gd/tests/imagearc_variation2.phpt @@ -0,0 +1,28 @@ +--TEST-- +Testing passing negative start angle to imagearc() of GD library +--CREDITS-- +Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(100, 100); + +$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); + +//create an arc with white color +imagearc($image, 50, 50, 30, 30, -90, 0, $white); + +ob_start(); +imagepng($image); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +463b4aea9d9acfab30016ee92613c779 diff --git a/ext/gd/tests/imagechar_basic.phpt b/ext/gd/tests/imagechar_basic.phpt new file mode 100644 index 0000000..7e5fa93 --- /dev/null +++ b/ext/gd/tests/imagechar_basic.phpt @@ -0,0 +1,25 @@ +--TEST-- +Testing imagechar() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$white = imagecolorallocate($image, 255,255,255); + +$result = imagechar($image, 1, 5, 5, 'C', $white); + +ob_start(); +imagepng($image, null, 9); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +e94962ac28ad03bd4142cb1abe9ef98b diff --git a/ext/gd/tests/imagechar_error1.phpt b/ext/gd/tests/imagechar_error1.phpt new file mode 100644 index 0000000..373d304 --- /dev/null +++ b/ext/gd/tests/imagechar_error1.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-resource parameter 1 of imagechar() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$result = imagechar('string', 1, 5, 5, 'C', 1); + +?> +--EXPECTF-- +Warning: imagechar() expects parameter 1 to be resource, %s given in %s on line %d diff --git a/ext/gd/tests/imagechar_error2.phpt b/ext/gd/tests/imagechar_error2.phpt new file mode 100644 index 0000000..02a9599 --- /dev/null +++ b/ext/gd/tests/imagechar_error2.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-image resource parameter 1 of imagechar() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$result = imagechar(tmpfile(), 1, 5, 5, 'C', 1); + +?> +--EXPECTF-- +Warning: imagechar(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagechar_error3.phpt b/ext/gd/tests/imagechar_error3.phpt new file mode 100644 index 0000000..aec65e9 --- /dev/null +++ b/ext/gd/tests/imagechar_error3.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 2 of imagechar() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagechar($image, 'string', 5, 5, 'C', 1); + +?> +--EXPECTF-- +Warning: imagechar() expects parameter 2 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagechar_error4.phpt b/ext/gd/tests/imagechar_error4.phpt new file mode 100644 index 0000000..a9485f7 --- /dev/null +++ b/ext/gd/tests/imagechar_error4.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 3 of imagechar() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagechar($image, 1, 'string', 5, 'C', 1); + +?> +--EXPECTF-- +Warning: imagechar() expects parameter 3 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagechar_error5.phpt b/ext/gd/tests/imagechar_error5.phpt new file mode 100644 index 0000000..8670d19 --- /dev/null +++ b/ext/gd/tests/imagechar_error5.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 4 of imagechar() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagechar($image, 1, 5, 'string', 'C', 1); + +?> +--EXPECTF-- +Warning: imagechar() expects parameter 4 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagechar_error6.phpt b/ext/gd/tests/imagechar_error6.phpt new file mode 100644 index 0000000..eaef2f8 --- /dev/null +++ b/ext/gd/tests/imagechar_error6.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-string parameter 5 of imagechar() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagechar($image, 1, 5, 5, $image, 1); + +?> +--EXPECTF-- +Warning: imagechar() expects parameter 5 to be string%S, %s given in %s on line %d diff --git a/ext/gd/tests/imagechar_error7.phpt b/ext/gd/tests/imagechar_error7.phpt new file mode 100644 index 0000000..fae23a7 --- /dev/null +++ b/ext/gd/tests/imagechar_error7.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 6 of imagechar() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagechar($image, 1, 5, 5, 'C', 'font'); + +?> +--EXPECTF-- +Warning: imagechar() expects parameter 6 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagecharup_basic.phpt b/ext/gd/tests/imagecharup_basic.phpt new file mode 100644 index 0000000..54c8dfa --- /dev/null +++ b/ext/gd/tests/imagecharup_basic.phpt @@ -0,0 +1,25 @@ +--TEST-- +Testing imagecharup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$white = imagecolorallocate($image, 255,255,255); + +$result = imagecharup($image, 1, 5, 5, 'C', $white); + +ob_start(); +imagepng($image, null, 9); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +79b48d5cef6d489bb68573df0296d775 diff --git a/ext/gd/tests/imagecharup_error1.phpt b/ext/gd/tests/imagecharup_error1.phpt new file mode 100644 index 0000000..e0b3e31 --- /dev/null +++ b/ext/gd/tests/imagecharup_error1.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-resource parameter 1 of imagecharup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$result = imagecharup('string', 1, 5, 5, 'C', 1); + +?> +--EXPECTF-- +Warning: imagecharup() expects parameter 1 to be resource, %s given in %s on line %d diff --git a/ext/gd/tests/imagecharup_error2.phpt b/ext/gd/tests/imagecharup_error2.phpt new file mode 100644 index 0000000..b78dc92 --- /dev/null +++ b/ext/gd/tests/imagecharup_error2.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-image resource parameter 1 of imagecharup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$result = imagecharup(tmpfile(), 1, 5, 5, 'C', 1); + +?> +--EXPECTF-- +Warning: imagecharup(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagecharup_error3.phpt b/ext/gd/tests/imagecharup_error3.phpt new file mode 100644 index 0000000..7e811ba --- /dev/null +++ b/ext/gd/tests/imagecharup_error3.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 2 of imagecharup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagecharup($image, 'string', 5, 5, 'C', 1); + +?> +--EXPECTF-- +Warning: imagecharup() expects parameter 2 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagecharup_error4.phpt b/ext/gd/tests/imagecharup_error4.phpt new file mode 100644 index 0000000..f76fdac --- /dev/null +++ b/ext/gd/tests/imagecharup_error4.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 3 of imagecharup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagecharup($image, 1, 'string', 5, 'C', 1); + +?> +--EXPECTF-- +Warning: imagecharup() expects parameter 3 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagecharup_error5.phpt b/ext/gd/tests/imagecharup_error5.phpt new file mode 100644 index 0000000..b565259 --- /dev/null +++ b/ext/gd/tests/imagecharup_error5.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 4 of imagecharup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagecharup($image, 1, 5, 'string', 'C', 1); + +?> +--EXPECTF-- +Warning: imagecharup() expects parameter 4 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagecharup_error6.phpt b/ext/gd/tests/imagecharup_error6.phpt new file mode 100644 index 0000000..a1f12f1 --- /dev/null +++ b/ext/gd/tests/imagecharup_error6.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-string parameter 5 of imagecharup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagecharup($image, 1, 5, 5, $image, 1); + +?> +--EXPECTF-- +Warning: imagecharup() expects parameter 5 to be string%S, %s given in %s on line %d diff --git a/ext/gd/tests/imagecharup_error7.phpt b/ext/gd/tests/imagecharup_error7.phpt new file mode 100644 index 0000000..b61189a --- /dev/null +++ b/ext/gd/tests/imagecharup_error7.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 6 of imagecharup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagecharup($image, 1, 5, 5, 'C', 'font'); + +?> +--EXPECTF-- +Warning: imagecharup() expects parameter 6 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagecolorallocate_basic.phpt b/ext/gd/tests/imagecolorallocate_basic.phpt new file mode 100644 index 0000000..25b2821 --- /dev/null +++ b/ext/gd/tests/imagecolorallocate_basic.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test imagecolorallocate() function : basic functionality +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('imagecreatetruecolor')) { + die('skip imagecreatetruecolor function is not available'); +} +?> +--FILE-- +<?php +/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue) + * Description: Allocate a color for an image + * Source code: ext/gd/gd.c + */ + +echo "*** Testing imagecolorallocate() : basic functionality ***\n"; + +$im = imagecreatetruecolor(200, 200); +// Calling imagecolorallocate() with all possible arguments +var_dump( imagecolorallocate($im, 255, 0, 0) ); +var_dump( imagecolorallocate($im, 0, 255, 0) ); +var_dump( imagecolorallocate($im, 0, 0, 255) ); +var_dump( imagecolorallocate($im, 255, 255, 255) ); +?> +===DONE=== +--EXPECTF-- +*** Testing imagecolorallocate() : basic functionality *** +int(16711680) +int(65280) +int(255) +int(16777215) +===DONE===
\ No newline at end of file diff --git a/ext/gd/tests/imagecolorallocate_error.phpt b/ext/gd/tests/imagecolorallocate_error.phpt new file mode 100644 index 0000000..6c685b2 --- /dev/null +++ b/ext/gd/tests/imagecolorallocate_error.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test imagecolorallocate() function : error conditions +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +?> +--FILE-- +<?php +/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue) + * Description: Allocate a color for an image + * Source code: ext/gd/gd.c + */ + +$red = 10; +$green = 10; +$blue = 10; +$extra_arg = 10; +$im = imagecreate(200, 200); + +echo "*** Testing imagecolorallocate() : error conditions ***\n"; + +//Test imagecolorallocate with one more than the expected number of arguments +echo "\n-- Testing imagecolorallocate() function with more than expected no. of arguments --\n"; +var_dump( imagecolorallocate($im, $red, $green, $blue, $extra_arg) ); + +// Testing imagecolorallocate with one less than the expected number of arguments +echo "\n-- Testing imagecolorallocate() function with less than expected no. of arguments --\n"; +var_dump( imagecolorallocate() ); +var_dump( imagecolorallocate($im, $red, $green) ); +?> +===DONE=== +--EXPECTF-- +*** Testing imagecolorallocate() : error conditions *** + +-- Testing imagecolorallocate() function with more than expected no. of arguments -- + +Warning: imagecolorallocate() expects exactly 4 parameters, 5 given in %s on line %d +NULL + +-- Testing imagecolorallocate() function with less than expected no. of arguments -- + +Warning: imagecolorallocate() expects exactly 4 parameters, 0 given in %s on line %d +NULL + +Warning: imagecolorallocate() expects exactly 4 parameters, 3 given in %s on line %d +NULL +===DONE===
\ No newline at end of file diff --git a/ext/gd/tests/imagecolorallocate_variation1.phpt b/ext/gd/tests/imagecolorallocate_variation1.phpt new file mode 100644 index 0000000..552a0fc --- /dev/null +++ b/ext/gd/tests/imagecolorallocate_variation1.phpt @@ -0,0 +1,267 @@ +--TEST-- +Test imagecolorallocate() function : usage variations - passing different data types to first argument +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +?> +--FILE-- +<?php +/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue) + * Description: Allocate a color for an image + * Source code: ext/gd/gd.c + */ + +echo "*** Testing imagecolorallocate() : usage variations ***\n"; + +// Initialise function arguments not being substituted (if any) +$red = 10; +$green = 10; +$blue = 10; + +$fp = tmpfile(); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); + + +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +//array of values to iterate over +$values = array( + + // int data + 'int 0' => 0, + 'int 1' => 1, + 'int 12345' => 12345, + 'int -12345' => -12345, + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 10.1234567e10' => 10.1234567e10, + 'float 10.7654321E-10' => 10.7654321E-10, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + //resource + "file resource" => $fp +); + +// loop through each element of the array for im +foreach($values as $key => $value) { + echo "\n-- $key --\n"; + var_dump( imagecolorallocate($value, $red, $green, $blue) ); +}; +?> +===DONE=== +--EXPECTF-- +*** Testing imagecolorallocate() : usage variations *** + +-- int 0 -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +-- int 1 -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +-- int 12345 -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +-- int -12345 -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, integer given in %s on line %d +NULL + +-- float 10.5 -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d +NULL + +-- float -10.5 -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d +NULL + +-- float 10.1234567e10 -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d +NULL + +-- float 10.7654321E-10 -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d +NULL + +-- float .5 -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, double given in %s on line %d +NULL + +-- empty array -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d +NULL + +-- int indexed array -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d +NULL + +-- associative array -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d +NULL + +-- nested arrays -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, array given in %s on line %d +NULL + +-- uppercase NULL -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d +NULL + +-- lowercase null -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d +NULL + +-- lowercase true -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +-- lowercase false -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +-- uppercase TRUE -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +-- uppercase FALSE -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, boolean given in %s on line %d +NULL + +-- empty string DQ -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d +NULL + +-- empty string SQ -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d +NULL + +-- string DQ -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d +NULL + +-- string SQ -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d +NULL + +-- mixed case string -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d +NULL + +-- heredoc -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, string given in %s on line %d +NULL + +-- instance of classWithToString -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, object given in %s on line %d +NULL + +-- instance of classWithoutToString -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, object given in %s on line %d +NULL + +-- undefined var -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d +NULL + +-- unset var -- + +Warning: imagecolorallocate() expects parameter 1 to be resource, null given in %s on line %d +NULL + +-- file resource -- + +Warning: imagecolorallocate(): supplied resource is not a valid Image resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/gd/tests/imagecolorallocate_variation2.phpt b/ext/gd/tests/imagecolorallocate_variation2.phpt new file mode 100644 index 0000000..bd9dc98 --- /dev/null +++ b/ext/gd/tests/imagecolorallocate_variation2.phpt @@ -0,0 +1,214 @@ +--TEST-- +Test imagecolorallocate() function : usage variations - passing different data types to second argument +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('imagecreatetruecolor')) { + die('skip imagecreatetruecolor function is not available'); +} +?> +--FILE-- +<?php +/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue) + * Description: Allocate a color for an image + * Source code: ext/gd/gd.c + */ + +echo "*** Testing imagecolorallocate() : usage variations ***\n"; + +$im = imagecreatetruecolor(200, 200); +$green = 10; +$blue = 10; + +$fp = tmpfile(); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +//array of values to iterate over +$values = array( + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 10.1234567e10' => 10.1234567e10, + 'float 10.7654321E-10' => 10.7654321E-10, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + //resource + "file resource" => $fp +); +// loop through each element of the array for red +foreach($values as $key => $value) { + echo "\n--$key--\n"; + var_dump( imagecolorallocate($im, $value, $green, $blue) ); +}; +?> +===DONE=== +--EXPECTF-- +*** Testing imagecolorallocate() : usage variations *** + +--float 10.5-- +int(657930) + +--float -10.5-- +bool(false) + +--float 10.1234567e10-- +bool(false) + +--float 10.7654321E-10-- +int(2570) + +--float .5-- +int(2570) + +--empty array-- + +Warning: imagecolorallocate() expects parameter 2 to be long, array given in %s on line %d +NULL + +--int indexed array-- + +Warning: imagecolorallocate() expects parameter 2 to be long, array given in %s on line %d +NULL + +--associative array-- + +Warning: imagecolorallocate() expects parameter 2 to be long, array given in %s on line %d +NULL + +--nested arrays-- + +Warning: imagecolorallocate() expects parameter 2 to be long, array given in %s on line %d +NULL + +--uppercase NULL-- +int(2570) + +--lowercase null-- +int(2570) + +--lowercase true-- +int(68106) + +--lowercase false-- +int(2570) + +--uppercase TRUE-- +int(68106) + +--uppercase FALSE-- +int(2570) + +--empty string DQ-- + +Warning: imagecolorallocate() expects parameter 2 to be long, string given in %s on line %d +NULL + +--empty string SQ-- + +Warning: imagecolorallocate() expects parameter 2 to be long, string given in %s on line %d +NULL + +--string DQ-- + +Warning: imagecolorallocate() expects parameter 2 to be long, string given in %s on line %d +NULL + +--string SQ-- + +Warning: imagecolorallocate() expects parameter 2 to be long, string given in %s on line %d +NULL + +--mixed case string-- + +Warning: imagecolorallocate() expects parameter 2 to be long, string given in %s on line %d +NULL + +--heredoc-- + +Warning: imagecolorallocate() expects parameter 2 to be long, string given in %s on line %d +NULL + +--instance of classWithToString-- + +Warning: imagecolorallocate() expects parameter 2 to be long, object given in %s on line %d +NULL + +--instance of classWithoutToString-- + +Warning: imagecolorallocate() expects parameter 2 to be long, object given in %s on line %d +NULL + +--undefined var-- +int(2570) + +--unset var-- +int(2570) + +--file resource-- + +Warning: imagecolorallocate() expects parameter 2 to be long, resource given in %s on line %d +NULL +===DONE=== diff --git a/ext/gd/tests/imagecolorallocate_variation3.phpt b/ext/gd/tests/imagecolorallocate_variation3.phpt new file mode 100644 index 0000000..c48dc29 --- /dev/null +++ b/ext/gd/tests/imagecolorallocate_variation3.phpt @@ -0,0 +1,214 @@ +--TEST-- +Test imagecolorallocate() function : usage variations - passing different data types to third argument +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('imagecreatetruecolor')) { + die('skip imagecreatetruecolor function is not available'); +} +?> +--FILE-- +<?php +/* Prototype : imagecolorallocate(resource im, int red, int green, int blue) + * Description: Allocate a color for an image + * Source code: ext/gd/gd.c + */ + +echo "*** Testing imagecolorallocate() : usage variations ***\n"; + +$im = imagecreatetruecolor(200, 200); +$red = 10; +$blue = 10; + +$fp = tmpfile(); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +//array of values to iterate over +$values = array( + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 10.1234567e5' => 10.1234567e5, + 'float 10.7654321E-5' => 10.7654321E-5, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + //resource + "file resource" => $fp +); +// loop through each element of the array for red +foreach($values as $key => $value) { + echo "\n--$key--\n"; + var_dump( imagecolorallocate($im, $red, $value, $blue) ); +}; +?> +===DONE=== +--EXPECTF-- +*** Testing imagecolorallocate() : usage variations *** + +--float 10.5-- +int(657930) + +--float -10.5-- +int(652810) + +--float 10.1234567e5-- +int(259815690) + +--float 10.7654321E-5-- +int(655370) + +--float .5-- +int(655370) + +--empty array-- + +Warning: imagecolorallocate() expects parameter 3 to be long, array given in %s on line %d +NULL + +--int indexed array-- + +Warning: imagecolorallocate() expects parameter 3 to be long, array given in %s on line %d +NULL + +--associative array-- + +Warning: imagecolorallocate() expects parameter 3 to be long, array given in %s on line %d +NULL + +--nested arrays-- + +Warning: imagecolorallocate() expects parameter 3 to be long, array given in %s on line %d +NULL + +--uppercase NULL-- +int(655370) + +--lowercase null-- +int(655370) + +--lowercase true-- +int(655626) + +--lowercase false-- +int(655370) + +--uppercase TRUE-- +int(655626) + +--uppercase FALSE-- +int(655370) + +--empty string DQ-- + +Warning: imagecolorallocate() expects parameter 3 to be long, string given in %s on line %d +NULL + +--empty string SQ-- + +Warning: imagecolorallocate() expects parameter 3 to be long, string given in %s on line %d +NULL + +--string DQ-- + +Warning: imagecolorallocate() expects parameter 3 to be long, string given in %s on line %d +NULL + +--string SQ-- + +Warning: imagecolorallocate() expects parameter 3 to be long, string given in %s on line %d +NULL + +--mixed case string-- + +Warning: imagecolorallocate() expects parameter 3 to be long, string given in %s on line %d +NULL + +--heredoc-- + +Warning: imagecolorallocate() expects parameter 3 to be long, string given in %s on line %d +NULL + +--instance of classWithToString-- + +Warning: imagecolorallocate() expects parameter 3 to be long, object given in %s on line %d +NULL + +--instance of classWithoutToString-- + +Warning: imagecolorallocate() expects parameter 3 to be long, object given in %s on line %d +NULL + +--undefined var-- +int(655370) + +--unset var-- +int(655370) + +--file resource-- + +Warning: imagecolorallocate() expects parameter 3 to be long, resource given in %s on line %d +NULL +===DONE===
\ No newline at end of file diff --git a/ext/gd/tests/imagecolorallocate_variation4.phpt b/ext/gd/tests/imagecolorallocate_variation4.phpt new file mode 100644 index 0000000..328a4cd --- /dev/null +++ b/ext/gd/tests/imagecolorallocate_variation4.phpt @@ -0,0 +1,213 @@ +--TEST-- +Test imagecolorallocate() function : usage variations - passing different data types to fourth argument +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('imagecreatetruecolor')) { + die('skip imagecreatetruecolor function is not available'); +} +?> +--FILE-- +<?php +/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue) + * Description: Allocate a color for an image + * Source code: ext/gd/gd.c + */ +echo "*** Testing imagecolorallocate() : usage variations ***\n"; + +$im = imagecreatetruecolor(200, 200); +$red = 10; +$green = 10; + +$fp = tmpfile(); + +//get an unset variable +$unset_var = 10; +unset ($unset_var); +// define some classes +class classWithToString +{ + public function __toString() { + return "Class A object"; + } +} + + +class classWithoutToString +{ +} + +// heredoc string +$heredoc = <<<EOT +hello world +EOT; + +// add arrays +$index_array = array (1, 2, 3); +$assoc_array = array ('one' => 1, 'two' => 2); + +//array of values to iterate over +$values = array( + + // float data + 'float 10.5' => 10.5, + 'float -10.5' => -10.5, + 'float 10.1234567e10' => 10.1234567e10, + 'float 10.7654321E-10' => 10.7654321E-10, + 'float .5' => .5, + + // array data + 'empty array' => array(), + 'int indexed array' => $index_array, + 'associative array' => $assoc_array, + 'nested arrays' => array('foo', $index_array, $assoc_array), + + // null data + 'uppercase NULL' => NULL, + 'lowercase null' => null, + + // boolean data + 'lowercase true' => true, + 'lowercase false' =>false, + 'uppercase TRUE' =>TRUE, + 'uppercase FALSE' =>FALSE, + + // empty data + 'empty string DQ' => "", + 'empty string SQ' => '', + + // string data + 'string DQ' => "string", + 'string SQ' => 'string', + 'mixed case string' => "sTrInG", + 'heredoc' => $heredoc, + + // object data + 'instance of classWithToString' => new classWithToString(), + 'instance of classWithoutToString' => new classWithoutToString(), + + // undefined data + 'undefined var' => @$undefined_var, + + // unset data + 'unset var' => @$unset_var, + + //resource + "file resource" => $fp +); +// loop through each element of the array for red +foreach($values as $key => $value) { + echo "\n--$key--\n"; + var_dump( imagecolorallocate($im, $red, $green, $value) ); +}; +?> +===DONE=== +--EXPECTF-- +*** Testing imagecolorallocate() : usage variations *** + +--float 10.5-- +int(657930) + +--float -10.5-- +int(657910) + +--float 10.1234567e10-- +bool(false) + +--float 10.7654321E-10-- +int(657920) + +--float .5-- +int(657920) + +--empty array-- + +Warning: imagecolorallocate() expects parameter 4 to be long, array given in %s on line %d +NULL + +--int indexed array-- + +Warning: imagecolorallocate() expects parameter 4 to be long, array given in %s on line %d +NULL + +--associative array-- + +Warning: imagecolorallocate() expects parameter 4 to be long, array given in %s on line %d +NULL + +--nested arrays-- + +Warning: imagecolorallocate() expects parameter 4 to be long, array given in %s on line %d +NULL + +--uppercase NULL-- +int(657920) + +--lowercase null-- +int(657920) + +--lowercase true-- +int(657921) + +--lowercase false-- +int(657920) + +--uppercase TRUE-- +int(657921) + +--uppercase FALSE-- +int(657920) + +--empty string DQ-- + +Warning: imagecolorallocate() expects parameter 4 to be long, string given in %s on line %d +NULL + +--empty string SQ-- + +Warning: imagecolorallocate() expects parameter 4 to be long, string given in %s on line %d +NULL + +--string DQ-- + +Warning: imagecolorallocate() expects parameter 4 to be long, string given in %s on line %d +NULL + +--string SQ-- + +Warning: imagecolorallocate() expects parameter 4 to be long, string given in %s on line %d +NULL + +--mixed case string-- + +Warning: imagecolorallocate() expects parameter 4 to be long, string given in %s on line %d +NULL + +--heredoc-- + +Warning: imagecolorallocate() expects parameter 4 to be long, string given in %s on line %d +NULL + +--instance of classWithToString-- + +Warning: imagecolorallocate() expects parameter 4 to be long, object given in %s on line %d +NULL + +--instance of classWithoutToString-- + +Warning: imagecolorallocate() expects parameter 4 to be long, object given in %s on line %d +NULL + +--undefined var-- +int(657920) + +--unset var-- +int(657920) + +--file resource-- + +Warning: imagecolorallocate() expects parameter 4 to be long, resource given in %s on line %d +NULL +===DONE===
\ No newline at end of file diff --git a/ext/gd/tests/imagecolorallocate_variation5.phpt b/ext/gd/tests/imagecolorallocate_variation5.phpt new file mode 100644 index 0000000..794abb3 --- /dev/null +++ b/ext/gd/tests/imagecolorallocate_variation5.phpt @@ -0,0 +1,90 @@ +--TEST-- +Test imagecolorallocate() function : usage variations - passing octal and hexa-decimal values +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('imagecreatetruecolor')) { + die('skip imagecreatetruecolor function is not available'); +} +?> +--FILE-- +<?php +/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue) + * Description: Allocate a color for an image + * Source code: ext/gd/gd.c + */ +echo "*** Testing imagecolorallocate() : usage variations ***\n"; + +$im = imagecreatetruecolor(200, 200); +$red = 10; +$green = 10; +$blue = 10; + +$values = array( + // octal integer data + "Octal 000" => 000, + "Octal 012" => 012, + "Octal -012" => -012, + "Octal 0377" => 0377, + + // hexa-decimal integer data + "Hexa-decimal 0x0" => 0x0, + "Hexa-decimal 0xA" => 0xA, + "Hexa-decimal -0xA" => -0xA, + "Hexa-decimal 0xFF" => 0xFF, +); + +// loop through each element of the array for blue +foreach($values as $key => $value) { + echo "\n--$key--\n"; + var_dump( imagecolorallocate($im, $value, $green, $blue) ); + var_dump( imagecolorallocate($im, $red, $value, $blue) ); + var_dump( imagecolorallocate($im, $red, $green, $value) ); +}; +?> +===DONE=== +--EXPECTF-- +*** Testing imagecolorallocate() : usage variations *** + +--Octal 000-- +int(2570) +int(655370) +int(657920) + +--Octal 012-- +int(657930) +int(657930) +int(657930) + +--Octal -012-- +bool(false) +int(652810) +int(657910) + +--Octal 0377-- +int(16714250) +int(720650) +int(658175) + +--Hexa-decimal 0x0-- +int(2570) +int(655370) +int(657920) + +--Hexa-decimal 0xA-- +int(657930) +int(657930) +int(657930) + +--Hexa-decimal -0xA-- +bool(false) +int(652810) +int(657910) + +--Hexa-decimal 0xFF-- +int(16714250) +int(720650) +int(658175) +===DONE=== diff --git a/ext/gd/tests/imagecolorallocate_variation6.phpt b/ext/gd/tests/imagecolorallocate_variation6.phpt new file mode 100644 index 0000000..bc939c9 --- /dev/null +++ b/ext/gd/tests/imagecolorallocate_variation6.phpt @@ -0,0 +1,56 @@ +--TEST-- +Test imagecolorallocate() function : usage variations - passing RED, GREEN, BLUE values more than 255 +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('imagecreatetruecolor')) { + die('skip imagecreatetruecolor function is not available'); +} +?> +--FILE-- +<?php +/* Prototype : int imagecolorallocate(resource im, int red, int green, int blue) + * Description: Allocate a color for an image + * Source code: ext/gd/gd.c + */ +echo "*** Testing imagecolorallocate() : usage variations ***\n"; + +$values = array( + //Decimal integera data + "Decimal 256" => 256, + + // octal integer data + "Octal 0400" => 0400, + + // hexa-decimal integer data + "Hexa-decimal 0x100" => 0x100 +); + +// loop through each element of the array for blue +foreach($values as $key => $value) { + echo "\n--$key--\n"; + //Need to be created every time to get expected return value + $im_palette = imagecreate(200, 200); + $im_true_color = imagecreatetruecolor(200, 200); + var_dump( imagecolorallocate($im_palette, $value, $value, $value) ); + var_dump( imagecolorallocate($im_true_color, $value, $value, $value) ); +}; +?> +===DONE=== +--EXPECTF-- +*** Testing imagecolorallocate() : usage variations *** + +--Decimal 256-- +int(0) +int(16843008) + +--Octal 0400-- +int(0) +int(16843008) + +--Hexa-decimal 0x100-- +int(0) +int(16843008) +===DONE=== diff --git a/ext/gd/tests/imagecolorallocatealpha_basic.phpt b/ext/gd/tests/imagecolorallocatealpha_basic.phpt new file mode 100644 index 0000000..720c500 --- /dev/null +++ b/ext/gd/tests/imagecolorallocatealpha_basic.phpt @@ -0,0 +1,30 @@ +--TEST-- +Testing imagecolorallocatealpha() +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$img = imagecreatetruecolor(150, 150); + +$cor = imagecolorallocate($img, 50, 100, 255); +$corA = imagecolorallocatealpha($img, 50, 100, 255, 50); +//$whiteA = imagecolorallocatealpha($img, 255, 255, 255, 127); + +$half = imagefilledarc ( $img, 75, 75, 70, 70, 0, 180, $cor, IMG_ARC_PIE ); +$half2 = imagefilledarc ( $img, 75, 75, 70, 70, 180, 360, $corA, IMG_ARC_PIE ); + +ob_start(); +imagepng($img, null, 9); +$imgsrc = ob_get_contents(); +ob_end_clean(); + +var_dump(md5(base64_encode($imgsrc))); +var_dump($corA); +?> +--EXPECT-- +string(32) "b856a0b1a15efe0f79551ebbb5651fe8" +int(842163455)
\ No newline at end of file diff --git a/ext/gd/tests/imagecolorallocatealpha_error1.phpt b/ext/gd/tests/imagecolorallocatealpha_error1.phpt new file mode 100644 index 0000000..a903024 --- /dev/null +++ b/ext/gd/tests/imagecolorallocatealpha_error1.phpt @@ -0,0 +1,25 @@ +--TEST-- +Testing imagecolorallocatealpha(): Wrong types for parameter 1 +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$resource = tmpfile(); + +imagecolorallocatealpha($resource, 255, 255, 255, 50); +imagecolorallocatealpha('string', 255, 255, 255, 50); +imagecolorallocatealpha(array(), 255, 255, 255, 50); +imagecolorallocatealpha(null, 255, 255, 255, 50); +?> +--EXPECTF-- +Warning: imagecolorallocatealpha(): supplied resource is not a valid Image resource in %s on line %d + +Warning: imagecolorallocatealpha() expects parameter 1 to be resource, %s given in %s on line %d + +Warning: imagecolorallocatealpha() expects parameter 1 to be resource, array given in %s on line %d + +Warning: imagecolorallocatealpha() expects parameter 1 to be resource, null given in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagecolorallocatealpha_error2.phpt b/ext/gd/tests/imagecolorallocatealpha_error2.phpt new file mode 100644 index 0000000..ba9e5de --- /dev/null +++ b/ext/gd/tests/imagecolorallocatealpha_error2.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing imagecolorallocatealpha(): Wrong types for parameter 2 +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$img = imagecreatetruecolor(200, 200); + +imagecolorallocatealpha($img, 'string-non-numeric', 255, 255, 50); +imagecolorallocatealpha($img, array(), 255, 255, 50); +imagecolorallocatealpha($img, tmpfile(), 255, 255, 50); +?> +--EXPECTF-- +Warning: imagecolorallocatealpha() expects parameter 2 to be long, %s given in %s on line %d + +Warning: imagecolorallocatealpha() expects parameter 2 to be long, array given in %s on line %d + +Warning: imagecolorallocatealpha() expects parameter 2 to be long, resource given in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagecolorallocatealpha_error3.phpt b/ext/gd/tests/imagecolorallocatealpha_error3.phpt new file mode 100644 index 0000000..ee8f646 --- /dev/null +++ b/ext/gd/tests/imagecolorallocatealpha_error3.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing imagecolorallocatealpha(): Wrong types for parameter 3 +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$img = imagecreatetruecolor(200, 200); + +imagecolorallocatealpha($img, 255, 'string-non-numeric', 255, 50); +imagecolorallocatealpha($img, 255, array(), 255, 50); +imagecolorallocatealpha($img, 255, tmpfile(), 255, 50); +?> +--EXPECTF-- +Warning: imagecolorallocatealpha() expects parameter 3 to be long, %s given in %s on line %d + +Warning: imagecolorallocatealpha() expects parameter 3 to be long, array given in %s on line %d + +Warning: imagecolorallocatealpha() expects parameter 3 to be long, resource given in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagecolorallocatealpha_error4.phpt b/ext/gd/tests/imagecolorallocatealpha_error4.phpt new file mode 100644 index 0000000..2b5b471 --- /dev/null +++ b/ext/gd/tests/imagecolorallocatealpha_error4.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing imagecolorallocatealpha(): Wrong types for parameter 4 +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$img = imagecreatetruecolor(200, 200); + +imagecolorallocatealpha($img, 255, 255, 'string-non-numeric', 50); +imagecolorallocatealpha($img, 255, 255, array(), 50); +imagecolorallocatealpha($img, 255, 255, tmpfile(), 50); +?> +--EXPECTF-- +Warning: imagecolorallocatealpha() expects parameter 4 to be long, %s given in %s on line %d + +Warning: imagecolorallocatealpha() expects parameter 4 to be long, array given in %s on line %d + +Warning: imagecolorallocatealpha() expects parameter 4 to be long, resource given in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagecolorallocatealpha_error5.phpt b/ext/gd/tests/imagecolorallocatealpha_error5.phpt new file mode 100644 index 0000000..2d77833 --- /dev/null +++ b/ext/gd/tests/imagecolorallocatealpha_error5.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing imagecolorallocatealpha(): Wrong types for parameter 5 +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$img = imagecreatetruecolor(200, 200); + +imagecolorallocatealpha($img, 255, 255, 255, 'string-non-numeric'); +imagecolorallocatealpha($img, 255, 255, 255, array()); +imagecolorallocatealpha($img, 255, 255, 255, tmpfile()); +?> +--EXPECTF-- +Warning: imagecolorallocatealpha() expects parameter 5 to be long, %s given in %s on line %d + +Warning: imagecolorallocatealpha() expects parameter 5 to be long, array given in %s on line %d + +Warning: imagecolorallocatealpha() expects parameter 5 to be long, resource given in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagecolorclosesthwb.phpt b/ext/gd/tests/imagecolorclosesthwb.phpt new file mode 100644 index 0000000..4266514 --- /dev/null +++ b/ext/gd/tests/imagecolorclosesthwb.phpt @@ -0,0 +1,30 @@ +--TEST-- +imagecolorclosesthwb() test +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip: gd extension not available'); } + if(!function_exists('imagecolorclosesthwb')){ die('skip: imagecolorclosesthwb() not available'); } +?> +--FILE-- +<?php + $im = imagecreatefrompng(dirname(__FILE__).'/test.png'); + + var_dump(imagecolorclosesthwb($im, 255, 50, 0)); + + var_dump(imagecolorclosesthwb(NULL)); + var_dump(imagecolorclosesthwb(NULL, NULL, NULL, NULL)); + var_dump(imagecolorclosesthwb($im, "hello", "from", "gd")); + + imagedestroy($im); +?> +--EXPECTF-- +int(16724480) + +Warning: imagecolorclosesthwb() expects exactly 4 parameters, 1 given in %s on line %d +NULL + +Warning: imagecolorclosesthwb() expects parameter 1 to be resource, null given in %s on line %d +NULL + +Warning: imagecolorclosesthwb() expects parameter 2 to be long, string given in %s on line %d +NULL diff --git a/ext/gd/tests/imagecolordeallocate_basic.phpt b/ext/gd/tests/imagecolordeallocate_basic.phpt new file mode 100644 index 0000000..3c80c69 --- /dev/null +++ b/ext/gd/tests/imagecolordeallocate_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing imagecolordeallocate() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +$white = imagecolorallocate($image, 255, 255, 255); +$result = imagecolordeallocate($image, $white); + +var_dump($result); + +?> +--EXPECT-- +bool(true) diff --git a/ext/gd/tests/imagecolordeallocate_error1.phpt b/ext/gd/tests/imagecolordeallocate_error1.phpt new file mode 100644 index 0000000..6d642d4 --- /dev/null +++ b/ext/gd/tests/imagecolordeallocate_error1.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing imagecolordeallocate() of GD library with invalid resource type +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(180, 30); +$white = imagecolorallocate($image, 255, 255, 255); + +$resource = tmpfile(); + +$result = imagecolordeallocate($resource, $white); + +?> +--EXPECTF-- +Warning: imagecolordeallocate(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagecolordeallocate_error2.phpt b/ext/gd/tests/imagecolordeallocate_error2.phpt new file mode 100644 index 0000000..989e0fd --- /dev/null +++ b/ext/gd/tests/imagecolordeallocate_error2.phpt @@ -0,0 +1,19 @@ +--TEST-- +Testing imagecolordeallocate() of GD library with no resource +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(180, 30); +$white = imagecolorallocate($image, 255, 255, 255); +$result = imagecolordeallocate('image', $white); + +?> +--EXPECTF-- +Warning: imagecolordeallocate() expects parameter 1 to be resource, %s given %s on line %d diff --git a/ext/gd/tests/imagecolordeallocate_error3.phpt b/ext/gd/tests/imagecolordeallocate_error3.phpt new file mode 100644 index 0000000..8000218 --- /dev/null +++ b/ext/gd/tests/imagecolordeallocate_error3.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing imagecolordeallocate() of GD library with Out of range intergers (Above) +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreate(180, 30); +$white = imagecolorallocate($image, 255, 255, 255); + +$totalColors = imagecolorstotal($image); + +$result = imagecolordeallocate($image, $totalColors + 100); +var_dump($result); +?> +--EXPECTF-- +Warning: imagecolordeallocate(): Color index 101 out of range in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagecolordeallocate_error4.phpt b/ext/gd/tests/imagecolordeallocate_error4.phpt new file mode 100644 index 0000000..7aaeffe --- /dev/null +++ b/ext/gd/tests/imagecolordeallocate_error4.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing imagecolordeallocate() of GD library with Out of range intergers (Below) +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreate(180, 30); +$white = imagecolorallocate($image, 255, 255, 255); + +$totalColors = imagecolorstotal($image); + +$result = imagecolordeallocate($image, -1.0); +var_dump($result); +?> +--EXPECTF-- +Warning: imagecolordeallocate(): Color index -1 out of range in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagecolormatch_basic.phpt b/ext/gd/tests/imagecolormatch_basic.phpt new file mode 100644 index 0000000..1d18812 --- /dev/null +++ b/ext/gd/tests/imagecolormatch_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +Basic test imagecolormatch() of GD library +--CREDITS-- +Paulo Alves de Sousa Filho <pspalves [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$ima = imagecreatetruecolor(110, 20); +$background_color = imagecolorallocate($ima, 0, 0, 0); +$imb = imagecreate(110, 20); +$background_color = imagecolorallocate($imb, 0, 0, 100); +var_dump(imagecolormatch($ima, $imb)); +?> +--EXPECTF-- +bool(true) diff --git a/ext/gd/tests/imagecolormatch_error1.phpt b/ext/gd/tests/imagecolormatch_error1.phpt new file mode 100644 index 0000000..9750a8b --- /dev/null +++ b/ext/gd/tests/imagecolormatch_error1.phpt @@ -0,0 +1,18 @@ +--TEST-- +Send only 1 parameter imagecolormatch() of GD library +--CREDITS-- +Paulo Alves de Sousa Filho <pspalves [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$ima = imagecreatetruecolor(110, 20); +$background_color = imagecolorallocate($ima, 0, 0, 0); +var_dump(imagecolormatch($ima)); +?> +--EXPECTF-- +Warning: imagecolormatch() expects exactly 2 parameters, %d given in %s on line %d +NULL diff --git a/ext/gd/tests/imagecolormatch_error2.phpt b/ext/gd/tests/imagecolormatch_error2.phpt new file mode 100644 index 0000000..bdb3c24 --- /dev/null +++ b/ext/gd/tests/imagecolormatch_error2.phpt @@ -0,0 +1,20 @@ +--TEST-- +Send not TrueColor to Image 1 parameter imagecolormatch() of GD library +--CREDITS-- +Paulo Alves de Sousa Filho <pspalves [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$ima = imagecreate(110, 20); +$background_color = imagecolorallocate($ima, 0, 0, 0); +$imb = imagecreate(110, 20); +$background_color = imagecolorallocate($imb, 0, 0, 100); +var_dump(imagecolormatch($ima, $imb)); +?> +--EXPECTF-- +Warning: imagecolormatch(): Image1 must be TrueColor in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagecolormatch_error3.phpt b/ext/gd/tests/imagecolormatch_error3.phpt new file mode 100644 index 0000000..8793e15 --- /dev/null +++ b/ext/gd/tests/imagecolormatch_error3.phpt @@ -0,0 +1,20 @@ +--TEST-- +Send not TrueColor to Image 1 parameter imagecolormatch() of GD library +--CREDITS-- +Paulo Alves de Sousa Filho <pspalves [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$ima = imagecreatetruecolor(110, 20); +$background_color = imagecolorallocate($ima, 0, 0, 0); +$imb = imagecreatetruecolor(110, 20); +$background_color = imagecolorallocate($imb, 0, 0, 100); +var_dump(imagecolormatch($ima, $imb)); +?> +--EXPECTF-- +Warning: imagecolormatch(): Image2 must be Palette in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagecolormatch_error4.phpt b/ext/gd/tests/imagecolormatch_error4.phpt new file mode 100644 index 0000000..0bfe767 --- /dev/null +++ b/ext/gd/tests/imagecolormatch_error4.phpt @@ -0,0 +1,20 @@ +--TEST-- +using different image sizes imagecolormatch() of GD library +--CREDITS-- +Paulo Alves de Sousa Filho <pspalves [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$ima = imagecreatetruecolor(110, 20); +$background_color = imagecolorallocate($ima, 0, 0, 0); +$imb = imagecreate(100, 20); +$background_color = imagecolorallocate($imb, 0, 0, 100); +var_dump(imagecolormatch($ima, $imb)); +?> +--EXPECTF-- +Warning: imagecolormatch(): Image1 and Image2 must be the same size in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagecolorset_basic.phpt b/ext/gd/tests/imagecolorset_basic.phpt new file mode 100644 index 0000000..a1776ff --- /dev/null +++ b/ext/gd/tests/imagecolorset_basic.phpt @@ -0,0 +1,35 @@ +--TEST-- +Test imagecolorset() function : basic functionality +--CREDITS-- +Erick Belluci Tedeschi <erickbt86 [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +?> +--FILE-- +<?php +// Create a 300x100 image +$im = imagecreate(300, 100); + +// Set the background to be red +imagecolorallocate($im, 255, 0, 0); + +// Get the color index for the background +$bg = imagecolorat($im, 0, 0); + +// Set the backgrund to be blue +imagecolorset($im, $bg, 0, 0, 255); + +// Get output and generate md5 hash +ob_start(); +imagepng($im, null, 9); +$result_image = ob_get_contents(); +ob_end_clean(); +echo md5(base64_encode($result_image)); +imagedestroy($im); +?> +--EXPECT-- +6f2002aafb57b2d275fad6a6258d7476 diff --git a/ext/gd/tests/imagecolorstotal_basic.phpt b/ext/gd/tests/imagecolorstotal_basic.phpt new file mode 100644 index 0000000..472a10d --- /dev/null +++ b/ext/gd/tests/imagecolorstotal_basic.phpt @@ -0,0 +1,36 @@ +--TEST-- +Test imagecolorstotal() function : basic functionality +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} + +if(!function_exists('imagecolorstotal') || !function_exists('imagecreatefromgif')) { + die('skip imagecolorstotal and imagecreatefromgif functions not available in this build'); +} +?> +--FILE-- +<?php +/* Prototype : int imagecolorstotal ( resource $image ) + * Description: Find out the number of colors in an image's palette + * Source code: ext/gd/gd.c + */ + +echo "*** Testing imagecolorstotal() : basic functionality ***\n"; + +// Get an image +$gif = dirname(__FILE__)."/php.gif"; +$im = imagecreatefromgif($gif); + +echo 'Total colors in image: ' . imagecolorstotal($im); + +// Free image +imagedestroy($im); +?> + +===DONE=== +--EXPECTF-- +*** Testing imagecolorstotal() : basic functionality *** +Total colors in image: 128 +===DONE===
\ No newline at end of file diff --git a/ext/gd/tests/imagecolorstotal_error.phpt b/ext/gd/tests/imagecolorstotal_error.phpt new file mode 100644 index 0000000..a7f3b95 --- /dev/null +++ b/ext/gd/tests/imagecolorstotal_error.phpt @@ -0,0 +1,54 @@ +--TEST-- +Test imagecolorstotal() function : error conditions - Pass incorrect number of arguments +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('imagecolorstotal')) { + die('skip imagecolorstotal function is not available'); +} +?> +--FILE-- +<?php +/* Prototype : int imagecolorstotal ( resource $image ) + * Description: Find out the number of colors in an image's palette + * Source code: ext/gd/gd.c + */ + +echo "*** Testing imagecolorstotal() : error conditions ***\n"; + +// Get a resource +$im = fopen(__FILE__, 'r'); + +echo "\n-- Testing imagecolorstotal() function with Zero arguments --\n"; +var_dump( imagecolorstotal() ); + +echo "\n-- Testing imagecolorstotal() function with more than expected no. of arguments --\n"; +$extra_arg = false; +var_dump( imagecolorstotal($im, $extra_arg) ); + +echo "\n-- Testing imagecolorstotal() function with a invalid resource\n"; +var_dump( imagecolorstotal($im) ); + +fclose($im); +?> +===DONE=== +--EXPECTF-- +*** Testing imagecolorstotal() : error conditions *** + +-- Testing imagecolorstotal() function with Zero arguments -- + +Warning: imagecolorstotal() expects exactly 1 parameter, 0 given in %s on line %d +NULL + +-- Testing imagecolorstotal() function with more than expected no. of arguments -- + +Warning: imagecolorstotal() expects exactly 1 parameter, 2 given in %s on line %d +NULL + +-- Testing imagecolorstotal() function with a invalid resource + +Warning: imagecolorstotal(): supplied resource is not a valid Image resource in %s on line %d +bool(false) +===DONE=== diff --git a/ext/gd/tests/imagecolourstotal_basic.phpt b/ext/gd/tests/imagecolourstotal_basic.phpt new file mode 100644 index 0000000..c26fa68 --- /dev/null +++ b/ext/gd/tests/imagecolourstotal_basic.phpt @@ -0,0 +1,50 @@ +--TEST-- +Test imagecolorstotal() function : basic functionality +--CREDITS-- +Felix De Vliegher <felix.devliegher@gmail.com> +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + if (!function_exists("imagecolorstotal")) { + die("skip imagecolorstotal() not available."); + } +?> +--FILE-- +<?php +/* Prototype : int imagecolorstotal(resource im) + * Description: Find out the number of colors in an image's palette + * Source code: ext/gd/gd.c + * Alias to functions: + */ + +echo "*** Testing imagecolorstotal() : basic functionality ***\n"; + +// Palette image +$img = imagecreate( 50, 50 ); +var_dump( imagecolorstotal( $img ) ); +$bg = imagecolorallocate( $img, 255, 255, 255 ); +var_dump( imagecolorstotal( $img )); +$bg = imagecolorallocate( $img, 255, 0, 0 ); +$bg = imagecolorallocate( $img, 0, 0, 255 ); +var_dump( imagecolorstotal( $img )); +imagedestroy( $img ); + +// Truecolor image +$img = imagecreatetruecolor( 50, 50 ); +var_dump( imagecolorstotal( $img ) ); +$bg = imagecolorallocate( $img, 255, 255, 255 ); +var_dump( imagecolorstotal( $img ) ); +imagedestroy( $img ); + +?> +===DONE=== +--EXPECTF-- +*** Testing imagecolorstotal() : basic functionality *** +int(0) +int(1) +int(3) +int(0) +int(0) +===DONE=== diff --git a/ext/gd/tests/imageconvolution_basic.phpt b/ext/gd/tests/imageconvolution_basic.phpt new file mode 100644 index 0000000..5a9aa8f --- /dev/null +++ b/ext/gd/tests/imageconvolution_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +Testing imageconvolution() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +// Writes the text and apply a gaussian blur on the image +imagestring($image, 5, 10, 8, 'Gaussian Blur Text', 0x00ff00); + +$gaussian = array( + array(1.0, 2.0, 1.0), + array(2.0, 4.0, 2.0), + array(1.0, 2.0, 1.0) +); + +imageconvolution($image, $gaussian, 16, 0); + +ob_start(); +imagepng($image, null, 9); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +594576a2a2a689447ffc07eb5a73f09b diff --git a/ext/gd/tests/imageconvolution_error1.phpt b/ext/gd/tests/imageconvolution_error1.phpt new file mode 100644 index 0000000..5dc250a --- /dev/null +++ b/ext/gd/tests/imageconvolution_error1.phpt @@ -0,0 +1,27 @@ +--TEST-- +Testing wrong param passing imageconvolution() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +// Writes the text and apply a gaussian blur on the image +imagestring($image, 5, 10, 8, 'Gaussian Blur Text', 0x00ff00); + +$gaussian = array( + array(1.0, 2.0, 1.0), + array(2.0, 4.0, 2.0), + array(1.0, 2.0, 1.0) +); + +var_dump(imageconvolution($image, $gaussian, 16)); +?> +--EXPECTF-- +Warning: imageconvolution() expects exactly 4 parameters, 3 given in %s on line %d +bool(false) diff --git a/ext/gd/tests/imageconvolution_error2.phpt b/ext/gd/tests/imageconvolution_error2.phpt new file mode 100644 index 0000000..5161c19 --- /dev/null +++ b/ext/gd/tests/imageconvolution_error2.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing wrong array size 2x3 in imageconvolution() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +// Writes the text and apply a gaussian blur on the image +imagestring($image, 5, 10, 8, 'Gaussian Blur Text', 0x00ff00); + +$gaussian = array( + array(1.0, 2.0, 1.0), + array(2.0, 4.0, 2.0) +); + +var_dump(imageconvolution($image, $gaussian, 16, 0)); +?> +--EXPECTF-- +Warning: imageconvolution(): You must have 3x3 array in %s on line %d +bool(false) diff --git a/ext/gd/tests/imageconvolution_error3.phpt b/ext/gd/tests/imageconvolution_error3.phpt new file mode 100644 index 0000000..df6b148 --- /dev/null +++ b/ext/gd/tests/imageconvolution_error3.phpt @@ -0,0 +1,27 @@ +--TEST-- +Testing wrong array size 3x2 in imageconvolution() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +// Writes the text and apply a gaussian blur on the image +imagestring($image, 5, 10, 8, 'Gaussian Blur Text', 0x00ff00); + +$gaussian = array( + array(1.0, 2.0, 1.0), + array(2.0, 4.0, 2.0), + array(1.0, 2.0) +); + +var_dump(imageconvolution($image, $gaussian, 16, 0)); +?> +--EXPECTF-- +Warning: imageconvolution(): You must have 3x3 array in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagecopymerge_basic.phpt b/ext/gd/tests/imagecopymerge_basic.phpt new file mode 100644 index 0000000..85f1162 --- /dev/null +++ b/ext/gd/tests/imagecopymerge_basic.phpt @@ -0,0 +1,30 @@ +--TEST-- +Testing imagecopymerge() of GD library +--CREDITS-- +Cleston Viel Vieira de Sousa <cleston [dot] vs [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$des = imagecreate(120, 120); +$src = imagecreate(100, 100); + +imagecolorallocate($des, 50, 50, 200); +$colorTXT_des = imagecolorallocate($des, 255, 255, 255); + +imagecolorallocate($src, 255, 255, 255); +$colorTXT_src = imagecolorallocate($src, 0, 255, 255); + +imagestring($src, 1, 5, 5, "A Simple Text", $colorTXT_src); +imagestring($des, 1, 5, 5, "Another Simple Text", $colorTXT_des); + +var_dump(imagecopymerge($des, $src, 20, 20, 0, 0, 50, 50, 75)); + + +?> +--EXPECTF-- +bool(true) diff --git a/ext/gd/tests/imagecopymerge_error.phpt b/ext/gd/tests/imagecopymerge_error.phpt new file mode 100644 index 0000000..e43bf69 --- /dev/null +++ b/ext/gd/tests/imagecopymerge_error.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing wrong parameter passing imagecopymerge() of GD library +--CREDITS-- +Cleston Viel Vieira de Sousa <cleston [dot] vs [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +imagecopymerge(); + +?> +--EXPECTF-- +Warning: imagecopymerge() expects exactly 9 parameters, 0 given in %s on line %d diff --git a/ext/gd/tests/imagecopyresampled_basic.phpt b/ext/gd/tests/imagecopyresampled_basic.phpt new file mode 100644 index 0000000..a0454fa --- /dev/null +++ b/ext/gd/tests/imagecopyresampled_basic.phpt @@ -0,0 +1,71 @@ +--TEST-- +imagecopyresampled() +--SKIPIF-- +<?php + if (!function_exists('imagecopyresampled')) die('skip imagecopyresampled() not available'); + if (!(imagetype() & IMG_PNG)) die('skip PNG Support is not enabled'); +?> +--FILE-- +<?php + +/* Prototype : bool imagecopyresampled ( resource $dst_image , resource $src_image , int $dst_x , int $dst_y , int $src_x , int $src_y , int $dst_w , int $dst_h , int $src_w , int $src_h ) + * Description: Copy and resize part of an image with resampling. + * Source code: ext/standard/image.c + * Alias to functions: + */ + +echo "Simple test of imagecopyresampled() function\n"; + +$dest_lge = dirname(realpath(__FILE__)) . '/imagelarge.png'; +$dest_sml = dirname(realpath(__FILE__)) . '/imagesmall.png'; + +// create a blank image +$image_lge = imagecreatetruecolor(400, 300); + +// set the background color to black +$bg = imagecolorallocate($image_lge, 0, 0, 0); + +// fill polygon with blue +$col_ellipse = imagecolorallocate($image_lge, 0, 255, 0); + +// draw the eclipse +imagefilledellipse($image_lge, 200, 150, 300, 200, $col_ellipse); + +// output the picture to a file +imagepng($image_lge, $dest_lge); + +// Get new dimensions +$percent = 0.5; // new image 50% of orginal +list($width, $height) = getimagesize($dest_lge); +echo "Size of orginal: width=". $width . " height=" . $height . "\n"; + +$new_width = $width * $percent; +$new_height = $height * $percent; + +// Resample +$image_sml = imagecreatetruecolor($new_width, $new_height); +imagecopyresampled($image_sml, $image_lge, 0, 0, 0, 0, $new_width, $new_height, $width, $height); + +imagepng($image_sml, $dest_sml); + +list($width, $height) = getimagesize($dest_sml); +echo "Size of copy: width=". $width . " height=" . $height . "\n"; + +imagedestroy($image_lge); +imagedestroy($image_sml); + + +echo "Done\n"; +?> +--CLEAN-- +<?php + $dest_lge = dirname(realpath(__FILE__)) . '/imagelarge.png'; + $dest_sml = dirname(realpath(__FILE__)) . '/imagesmall.png'; + @unlink($dest_lge); + @unlink($dest_sml); +?> +--EXPECT-- +Simple test of imagecopyresampled() function +Size of orginal: width=400 height=300 +Size of copy: width=200 height=150 +Done diff --git a/ext/gd/tests/imagecreatetruecolor_basic.phpt b/ext/gd/tests/imagecreatetruecolor_basic.phpt new file mode 100644 index 0000000..5c85f52 --- /dev/null +++ b/ext/gd/tests/imagecreatetruecolor_basic.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing imagecreatetruecolor() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +ob_start(); +imagepng($image, null, 9); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +5a8fe9864cbd20e5dbe730c77f30db95 diff --git a/ext/gd/tests/imagecreatetruecolor_error1.phpt b/ext/gd/tests/imagecreatetruecolor_error1.phpt new file mode 100644 index 0000000..e161688 --- /dev/null +++ b/ext/gd/tests/imagecreatetruecolor_error1.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing imagecreatetruecolor(): error on non-long parameters +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor('s', 30); +$image = imagecreatetruecolor(30, 's'); +?> +--EXPECTF-- +Warning: imagecreatetruecolor() expects parameter 1 to be long, %s given in %s on line %d + +Warning: imagecreatetruecolor() expects parameter 2 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagecreatetruecolor_error2.phpt b/ext/gd/tests/imagecreatetruecolor_error2.phpt new file mode 100644 index 0000000..e4de7e3 --- /dev/null +++ b/ext/gd/tests/imagecreatetruecolor_error2.phpt @@ -0,0 +1,24 @@ +--TEST-- +Testing imagecreatetruecolor(): error on out of bound parameters +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(-1, 30); +$image = imagecreatetruecolor(30, -1); +$image = imagecreatetruecolor(999999999999999999999999999, 30); +$image = imagecreatetruecolor(30, 999999999999999999999999999); +?> +--EXPECTF-- +Warning: imagecreatetruecolor(): Invalid image dimensions in %s on line %d + +Warning: imagecreatetruecolor(): Invalid image dimensions in %s on line %d + +Warning: imagecreatetruecolor(): Invalid image dimensions in %s on line %d + +Warning: imagecreatetruecolor(): Invalid image dimensions in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagecreatetruecolor_error3.phpt b/ext/gd/tests/imagecreatetruecolor_error3.phpt new file mode 100644 index 0000000..332cdef --- /dev/null +++ b/ext/gd/tests/imagecreatetruecolor_error3.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing imagecreatetruecolor(): error on wrong parameter count +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(); +$image = imagecreatetruecolor(30); +$image = imagecreatetruecolor(1,1,1); +?> +--EXPECTF-- +Warning: imagecreatetruecolor() expects exactly 2 parameters, 0 given in %s on line %d + +Warning: imagecreatetruecolor() expects exactly 2 parameters, 1 given in %s on line %d + +Warning: imagecreatetruecolor() expects exactly 2 parameters, 3 given in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagedashedline_basic.phpt b/ext/gd/tests/imagedashedline_basic.phpt new file mode 100644 index 0000000..be65af6 --- /dev/null +++ b/ext/gd/tests/imagedashedline_basic.phpt @@ -0,0 +1,78 @@ +--TEST-- +imagedashedline() +--SKIPIF-- +<?php + if (!function_exists('imagedashedline')) die('skip imagedashedline() not available'); + if (!(imagetype() & IMG_PNG)) die('skip PNG Support is not enabled'); +?> +--FILE-- +<?php + +/* Prototype : bool imagedashedline ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color ) + * Description: Draws a dashed line. + * This function is deprecated. Use combination of imagesetstyle() and imageline() instead. + * Source code: ext/standard/image.c + * Alias to functions: + */ + + +echo "Simple test of imagedashedline() function\n"; + +$dest = dirname(realpath(__FILE__)) . '/imagedashedline.png'; + +// create a blank image +$image = imagecreatetruecolor(250, 250); + +// set the background color to black +$bg = imagecolorallocate($image, 0, 0, 0); + +// red dashed lines +$col_line = imagecolorallocate($image, 255, 0, 0); + +// draw a couple of vertical dashed lines +imagedashedline($image, 100, 20, 100, 230, $col_line ); +imagedashedline($image, 150, 20, 150, 230, $col_line ); + +// output the picture to a file +imagepng($image, $dest); + +//check color of a point on edge.. +$col1 = imagecolorat($image, 100, 230); +// ..and a point on background +$col2 = imagecolorat($image, 5, 5); + +$color1 = imagecolorsforindex($image, $col1); +$color2 = imagecolorsforindex($image, $col2); +var_dump($color1, $color2); + +imagedestroy($image); +echo "Done\n"; +?> +--CLEAN-- +<?php + $dest = dirname(realpath(__FILE__)) . '/imagedashedline.png'; + @unlink($dest); +?> +--EXPECT-- +Simple test of imagedashedline() function +array(4) { + ["red"]=> + int(255) + ["green"]=> + int(0) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +array(4) { + ["red"]=> + int(0) + ["green"]=> + int(0) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +Done diff --git a/ext/gd/tests/imageellipse_basic.phpt b/ext/gd/tests/imageellipse_basic.phpt new file mode 100644 index 0000000..bfd0b79 --- /dev/null +++ b/ext/gd/tests/imageellipse_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +Testing imageellipse() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +// Create a image +$image = imagecreatetruecolor(400, 300); + +// Draw a white ellipse +imageellipse($image, 200, 150, 300, 200, 16777215); + +ob_start(); +imagepng($image, null, 9); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +d8b9bc2ca224bd68569413f4617f8e1f diff --git a/ext/gd/tests/imageellipse_error1.phpt b/ext/gd/tests/imageellipse_error1.phpt new file mode 100644 index 0000000..aa8ad78 --- /dev/null +++ b/ext/gd/tests/imageellipse_error1.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing wrong param passing imageellipse() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-30 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +// Create a image +$image = imagecreatetruecolor(400, 300); + +// try to draw a white ellipse +imageellipse('wrong param', 200, 150, 300, 200, 16777215); + +?> +--EXPECTF-- +Warning: imageellipse() expects parameter 1 to be resource, %s given in %s on line %d diff --git a/ext/gd/tests/imageellipse_error2.phpt b/ext/gd/tests/imageellipse_error2.phpt new file mode 100644 index 0000000..5b65bf8 --- /dev/null +++ b/ext/gd/tests/imageellipse_error2.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing wrong param passing imageellipse() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +// Create a image +$image = imagecreatetruecolor(400, 300); + +// try to draw a white ellipse +imageellipse($image, 'wrong param', 150, 300, 200, 16777215); + +?> +--EXPECTF-- +Warning: imageellipse() expects parameter 2 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imageellipse_error3.phpt b/ext/gd/tests/imageellipse_error3.phpt new file mode 100644 index 0000000..cbac2f0 --- /dev/null +++ b/ext/gd/tests/imageellipse_error3.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing wrong param passing imageellipse() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +// Create a image +$image = imagecreatetruecolor(400, 300); + +// try to draw a white ellipse +imageellipse($image, 200, 'wrong param', 300, 200, 16777215); + +?> +--EXPECTF-- +Warning: imageellipse() expects parameter 3 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imageellipse_error4.phpt b/ext/gd/tests/imageellipse_error4.phpt new file mode 100644 index 0000000..dec2e0f --- /dev/null +++ b/ext/gd/tests/imageellipse_error4.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing wrong param passing imageellipse() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +// Create a image +$image = imagecreatetruecolor(400, 300); + +// try to draw a white ellipse +imageellipse($image, 200, 150, 'wrong param', 200, 16777215); + +?> +--EXPECTF-- +Warning: imageellipse() expects parameter 4 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imageellipse_error5.phpt b/ext/gd/tests/imageellipse_error5.phpt new file mode 100644 index 0000000..4272470 --- /dev/null +++ b/ext/gd/tests/imageellipse_error5.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing wrong param passing imageellipse() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +// Create a image +$image = imagecreatetruecolor(400, 300); + +// try to draw a white ellipse +imageellipse($image, 200, 150, 300, 'wrong param', 16777215); + +?> +--EXPECTF-- +Warning: imageellipse() expects parameter 5 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imageellipse_error6.phpt b/ext/gd/tests/imageellipse_error6.phpt new file mode 100644 index 0000000..8628525 --- /dev/null +++ b/ext/gd/tests/imageellipse_error6.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing wrong param passing imageellipse() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +// Create a image +$image = imagecreatetruecolor(400, 300); + +// try to draw a white ellipse +imageellipse($image, 200, 150, 300, 200, 'wrong param'); + +?> +--EXPECTF-- +Warning: imageellipse() expects parameter 6 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imageellipse_error7.phpt b/ext/gd/tests/imageellipse_error7.phpt new file mode 100644 index 0000000..23f1eee --- /dev/null +++ b/ext/gd/tests/imageellipse_error7.phpt @@ -0,0 +1,20 @@ +--TEST-- +Testing wrong param passing imageellipse() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +// Create a resource +$image = tmpfile(); + +// try to draw a white ellipse +imageellipse($image, 200, 150, 300, 200, 16777215); +?> +--EXPECTF-- +Warning: imageellipse(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imageellipse_error8.phpt b/ext/gd/tests/imageellipse_error8.phpt new file mode 100644 index 0000000..3fefb56 --- /dev/null +++ b/ext/gd/tests/imageellipse_error8.phpt @@ -0,0 +1,21 @@ +--TEST--
+Testing wrong param passing imageellipse() of GD library
+--CREDITS--
+Ivan Rosolen <contato [at] ivanrosolen [dot] com>
+#testfest PHPSP on 2009-06-20
+--SKIPIF--
+<?php
+if ( ! extension_loaded("gd") ) die( 'skip GD not present; skipping test' );
+?>
+--FILE--
+<?php
+
+// Create a image
+$image = imagecreatetruecolor( 400, 300 );
+
+// try to draw a white ellipse
+imageellipse( $image, 200, 150, 300, 200 );
+
+?>
+--EXPECTF--
+Warning: imageellipse() expects exactly 6 parameters, %d given in %s on line %d diff --git a/ext/gd/tests/imagefill_1.phpt b/ext/gd/tests/imagefill_1.phpt new file mode 100644 index 0000000..04e1cab --- /dev/null +++ b/ext/gd/tests/imagefill_1.phpt @@ -0,0 +1,25 @@ +--TEST-- +imagefill() infinite loop with wrong color index +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + if (!function_exists("imagefttext")) { + die("skip imagefttext() not available."); + } +?> +--FILE-- +<?php +$im = imagecreate(100,100); +$white = imagecolorallocate($im, 255,255,255); +$blue = imagecolorallocate($im, 0,0,255); +$green = imagecolorallocate($im, 0,255,0); + +print_r(imagecolorat($im, 0,0)); +imagefill($im, 0,0,$white + 3); +print_r(imagecolorat($im, 0,0)); +imagedestroy($im); +?> +--EXPECT-- +00 diff --git a/ext/gd/tests/imagefilledarc_basic.phpt b/ext/gd/tests/imagefilledarc_basic.phpt new file mode 100644 index 0000000..9ff9bd3 --- /dev/null +++ b/ext/gd/tests/imagefilledarc_basic.phpt @@ -0,0 +1,28 @@ +--TEST-- +Testing imagefilledarc() of GD library +--CREDITS-- +Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(100, 100); + +$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); + +//create an arc and fill it with white color +imagefilledarc($image, 50, 50, 30, 30, 0, 90, $white, IMG_ARC_PIE); + +ob_start(); +imagepng($image); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +894f394c7f2e2364642ef27fea6bfc33 diff --git a/ext/gd/tests/imagefilledarc_error1.phpt b/ext/gd/tests/imagefilledarc_error1.phpt new file mode 100644 index 0000000..b2bc417 --- /dev/null +++ b/ext/gd/tests/imagefilledarc_error1.phpt @@ -0,0 +1,29 @@ +--TEST-- +Testing wrong param passing imagefilledarc() of GD library +--CREDITS-- +Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(100, 100); + +$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); + +//create an arc and fill it with white color +imagefilledarc($image, 50, 50, 30, 30, 0, 90, $white); + +ob_start(); +imagepng($image); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECTF-- +Warning: imagefilledarc() expects exactly 9 parameters, 8 given in %s on line %d +abebb25b5a2813cfbf92f1f24365786a diff --git a/ext/gd/tests/imagefilledarc_variation1.phpt b/ext/gd/tests/imagefilledarc_variation1.phpt new file mode 100644 index 0000000..2dec1ea --- /dev/null +++ b/ext/gd/tests/imagefilledarc_variation1.phpt @@ -0,0 +1,28 @@ +--TEST-- +Testing passing negative end angle to imagefilledarc() of GD library +--CREDITS-- +Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(100, 100); + +$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); + +//create an arc and fill it with white color +imagefilledarc($image, 50, 50, 30, 30, 0, -25, $white, IMG_ARC_PIE); + +ob_start(); +imagepng($image); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +b77bbb8207e5adbebfcc8bd1c4074305 diff --git a/ext/gd/tests/imagefilledarc_variation2.phpt b/ext/gd/tests/imagefilledarc_variation2.phpt new file mode 100644 index 0000000..5c8ffba --- /dev/null +++ b/ext/gd/tests/imagefilledarc_variation2.phpt @@ -0,0 +1,28 @@ +--TEST-- +Testing passing negative start angle to imagefilledarc() of GD library +--CREDITS-- +Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(100, 100); + +$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); + +//create an arc and fill it with white color +imagefilledarc($image, 50, 50, 30, 30, -25, 25, $white, IMG_ARC_PIE); + +ob_start(); +imagepng($image); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +b8b572812b3c85678f6c38c4ecca7619 diff --git a/ext/gd/tests/imagefilledpolygon_basic.phpt b/ext/gd/tests/imagefilledpolygon_basic.phpt new file mode 100644 index 0000000..ded52da --- /dev/null +++ b/ext/gd/tests/imagefilledpolygon_basic.phpt @@ -0,0 +1,102 @@ +--TEST-- +imagefilledpolygon() +--SKIPIF-- +<?php + if (!function_exists('imagefilledpolygon')) die('skip imagefilledpolygon() not available'); + if (!(imagetype() & IMG_PNG)) die('skip PNG Support is not enabled'); +?> +--FILE-- +<?php + +/* Prototype : bool imagefilledpolygon ( resource $image , array $points , int $num_points , int $color ) + * Description: Draws a filled polygon. + * Source code: ext/standard/image.c + * Alias to functions: + */ + +echo "Simple test of imagefilledpolygon() function\n"; + +$dest = dirname(realpath(__FILE__)) . '/imagefilledpolygon.png'; + +$points = array( + 40, 50, + 20, 240, + 60, 60, + 240, 20, + 50, 40, + 10, 10 + ); + +// create a blank image +$image = imagecreatetruecolor(250, 250); + +// set the background color to black +$bg = imagecolorallocate($image, 0, 0, 0); + +// fill polygon with green +$col_poly = imagecolorallocate($image, 0, 255, 0); + +// draw the polygon +imagefilledpolygon($image, $points, count($points)/2, $col_poly); + +// output the picture to a file +imagepng($image, $dest); + +// get it back +$image_in = imagecreatefrompng($dest); + +//check color of a point on edge.. +$col1 = imagecolorat($image_in, 40, 50); +//.. a point in filled body +$col2 = imagecolorat($image_in, 15, 15); +// ..and a point on background +$col3 = imagecolorat($image_in, 5, 5); + +$color1 = imagecolorsforindex($image_in, $col1); +$color2 = imagecolorsforindex($image_in, $col2); +$color3 = imagecolorsforindex($image_in, $col3); +var_dump($color1, $color2, $color3); + +imagedestroy($image); +imagedestroy($image_in); + +echo "Done\n"; +?> +--CLEAN-- +<?php + $dest = dirname(realpath(__FILE__)) . '/imagefilledpolygon.png'; + @unlink($dest); +?> +--EXPECT-- +Simple test of imagefilledpolygon() function +array(4) { + ["red"]=> + int(0) + ["green"]=> + int(255) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +array(4) { + ["red"]=> + int(0) + ["green"]=> + int(255) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +array(4) { + ["red"]=> + int(0) + ["green"]=> + int(0) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +Done diff --git a/ext/gd/tests/imagefilledpolygon_negative.phpt b/ext/gd/tests/imagefilledpolygon_negative.phpt new file mode 100644 index 0000000..ced8530 --- /dev/null +++ b/ext/gd/tests/imagefilledpolygon_negative.phpt @@ -0,0 +1,15 @@ +--TEST-- +imagefilledpolygon() with a negative num of points +--SKIPIF-- +<?php + if (!function_exists('imagefilledpolygon')) die('skip imagefilledpolygon() not available'); +?> +--FILE-- +<?php +$im = imagecreate(100, 100); +$black = imagecolorallocate($im, 0, 0, 0); +if (imagefilledpolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black)) echo "should be false"; +imagedestroy($im); +?> +--EXPECTF-- +Warning: imagefilledpolygon(): You must give a positive number of points in %s on line %d diff --git a/ext/gd/tests/imagefilltoborder_basic.phpt b/ext/gd/tests/imagefilltoborder_basic.phpt new file mode 100644 index 0000000..80b84d2 --- /dev/null +++ b/ext/gd/tests/imagefilltoborder_basic.phpt @@ -0,0 +1,33 @@ +--TEST-- +Testing imagefilltoborder() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-30 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +// Create a image +$image = imagecreatetruecolor( 100, 100 ); + +// Draw a rectangle +imagefilledrectangle( $image, 0, 0, 100, 100, imagecolorallocate( $image, 255, 255, 255 ) ); + +// Draw an ellipse to fill with a black border +imageellipse( $image, 50, 50, 50, 50, imagecolorallocate( $image, 0, 0, 0 ) ); + +// Fill border +imagefilltoborder( $image, 50, 50, imagecolorallocate( $image, 0, 0, 0 ), imagecolorallocate( $image, 255, 0, 0 ) ); + +ob_start(); +imagepng( $image, null, 9 ); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); + +?> +--EXPECT-- +847ec236f1c4d14c465306c8408550fc diff --git a/ext/gd/tests/imagefilltoborder_error1.phpt b/ext/gd/tests/imagefilltoborder_error1.phpt new file mode 100644 index 0000000..9412da7 --- /dev/null +++ b/ext/gd/tests/imagefilltoborder_error1.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing wrong param passing imagefilltoborder() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-30 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +// Create a image +$image = imagecreatetruecolor( 100, 100 ); + +// Draw a rectangle +imagefilledrectangle( $image, 0, 0, 100, 100, imagecolorallocate( $image, 255, 255, 255 ) ); + +// Draw an ellipse to fill with a black border +imageellipse( $image, 50, 50, 50, 50, imagecolorallocate( $image, 0, 0, 0 ) ); + +// Try to fill border +imagefilltoborder( 'wrong param', 50, 50, imagecolorallocate( $image, 0, 0, 0 ), imagecolorallocate( $image, 255, 0, 0 ) ); + +?> +--EXPECTF-- +Warning: imagefilltoborder() expects parameter 1 to be resource, %s given in %s on line %d diff --git a/ext/gd/tests/imagefilltoborder_error2.phpt b/ext/gd/tests/imagefilltoborder_error2.phpt new file mode 100644 index 0000000..dcbf904 --- /dev/null +++ b/ext/gd/tests/imagefilltoborder_error2.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing wrong param passing imagefilltoborder() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-30 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +// Create a image +$image = imagecreatetruecolor( 100, 100 ); + +// Draw a rectangle +imagefilledrectangle( $image, 0, 0, 100, 100, imagecolorallocate( $image, 255, 255, 255 ) ); + +// Draw an ellipse to fill with a black border +imageellipse( $image, 50, 50, 50, 50, imagecolorallocate( $image, 0, 0, 0 ) ); + +// Try to fill border +imagefilltoborder( $image, 'wrong param', 50, imagecolorallocate( $image, 0, 0, 0 ), imagecolorallocate( $image, 255, 0, 0 ) ); + +?> +--EXPECTF-- +Warning: imagefilltoborder() expects parameter 2 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagefilltoborder_error3.phpt b/ext/gd/tests/imagefilltoborder_error3.phpt new file mode 100644 index 0000000..73f6cf7 --- /dev/null +++ b/ext/gd/tests/imagefilltoborder_error3.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing wrong param passing imagefilltoborder() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-30 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +// Create a image +$image = imagecreatetruecolor( 100, 100 ); + +// Draw a rectangle +imagefilledrectangle( $image, 0, 0, 100, 100, imagecolorallocate( $image, 255, 255, 255 ) ); + +// Draw an ellipse to fill with a black border +imageellipse( $image, 50, 50, 50, 50, imagecolorallocate( $image, 0, 0, 0 ) ); + +// Try to fill border +imagefilltoborder( $image, 50, 'wrong param', imagecolorallocate( $image, 0, 0, 0 ), imagecolorallocate( $image, 255, 0, 0 ) ); + +?> +--EXPECTF-- +Warning: imagefilltoborder() expects parameter 3 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagefilltoborder_error4.phpt b/ext/gd/tests/imagefilltoborder_error4.phpt new file mode 100644 index 0000000..a5073d8 --- /dev/null +++ b/ext/gd/tests/imagefilltoborder_error4.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing wrong param passing imagefilltoborder() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-30 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +// Create a image +$image = imagecreatetruecolor( 100, 100 ); + +// Draw a rectangle +imagefilledrectangle( $image, 0, 0, 100, 100, imagecolorallocate( $image, 255, 255, 255 ) ); + +// Draw an ellipse to fill with a black border +imageellipse( $image, 50, 50, 50, 50, imagecolorallocate( $image, 0, 0, 0 ) ); + +// Try to fill border +imagefilltoborder( $image, 50, 50, 'wrong param', imagecolorallocate( $image, 255, 0, 0 ) ); + +?> +--EXPECTF-- +Warning: imagefilltoborder() expects parameter 4 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagefilltoborder_error5.phpt b/ext/gd/tests/imagefilltoborder_error5.phpt new file mode 100644 index 0000000..eff344a --- /dev/null +++ b/ext/gd/tests/imagefilltoborder_error5.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing wrong param passing imagefilltoborder() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-30 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +// Create a image +$image = imagecreatetruecolor( 100, 100 ); + +// Draw a rectangle +imagefilledrectangle( $image, 0, 0, 100, 100, imagecolorallocate( $image, 255, 255, 255 ) ); + +// Draw an ellipse to fill with a black border +imageellipse( $image, 50, 50, 50, 50, imagecolorallocate( $image, 0, 0, 0 ) ); + +// Try to fill border +imagefilltoborder( $image, 50, 50, imagecolorallocate( $image, 0, 0, 0 ), 'wrong param' ); + +?> +--EXPECTF-- +Warning: imagefilltoborder() expects parameter 5 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagefilltoborder_error6.phpt b/ext/gd/tests/imagefilltoborder_error6.phpt new file mode 100644 index 0000000..b5ce53b --- /dev/null +++ b/ext/gd/tests/imagefilltoborder_error6.phpt @@ -0,0 +1,29 @@ +--TEST-- +Testing wrong param passing imagefilltoborder() of GD library +--CREDITS-- +Ivan Rosolen <contato [at] ivanrosolen [dot] com> +#testfest PHPSP on 2009-06-30 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +// Create a image +$image = imagecreatetruecolor( 100, 100 ); + +// Draw a rectangle +imagefilledrectangle( $image, 0, 0, 100, 100, imagecolorallocate( $image, 255, 255, 255 ) ); + +// Draw an ellipse to fill with a black border +imageellipse( $image, 50, 50, 50, 50, imagecolorallocate( $image, 0, 0, 0 ) ); + +// Try to fill border +$image_foo = tmpfile(); +imagefilltoborder( $image_foo, 50, 50, imagecolorallocate( $image, 0, 0, 0 ), imagecolorallocate( $image, 255, 0, 0 ) ); + +?> +--EXPECTF-- +Warning: imagefilltoborder(): supplied resource is not a valid Image resource in %s on line %d + + diff --git a/ext/gd/tests/imagefilltoborder_error7.phpt b/ext/gd/tests/imagefilltoborder_error7.phpt new file mode 100644 index 0000000..aeb7d82 --- /dev/null +++ b/ext/gd/tests/imagefilltoborder_error7.phpt @@ -0,0 +1,26 @@ +--TEST--
+Testing wrong param passing imagefilltoborder() of GD library
+--CREDITS--
+Ivan Rosolen <contato [at] ivanrosolen [dot] com>
+#testfest PHPSP on 2009-06-30
+--SKIPIF--
+<?php
+if ( ! extension_loaded("gd")) die("skip GD not present; skipping test");
+?>
+--FILE--
+<?php
+// Create a image
+$image = imagecreatetruecolor( 100, 100 );
+
+// Draw a rectangle
+imagefilledrectangle( $image, 0, 0, 100, 100, imagecolorallocate( $image, 255, 255, 255 ) );
+
+// Draw an ellipse to fill with a black border
+imageellipse( $image, 50, 50, 50, 50, imagecolorallocate( $image, 0, 0, 0 ) );
+
+// Try to fill border
+imagefilltoborder( $image, 50, 50 );
+
+?>
+--EXPECTF--
+Warning: imagefilltoborder() expects exactly 5 parameters, %d given in %s on line %d diff --git a/ext/gd/tests/imagefilter.phpt b/ext/gd/tests/imagefilter.phpt new file mode 100644 index 0000000..8b17fb8 --- /dev/null +++ b/ext/gd/tests/imagefilter.phpt @@ -0,0 +1,98 @@ +--TEST-- +imagefilter() function test +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + if (!function_exists("imagefilter")) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php +$no_arg_filters = array( + "IMG_FILTER_NEGATE", + "IMG_FILTER_GRAYSCALE", + "IMG_FILTER_EDGEDETECT", + "IMG_FILTER_GAUSSIAN_BLUR", + "IMG_FILTER_SELECTIVE_BLUR", + "IMG_FILTER_EMBOSS", + "IMG_FILTER_MEAN_REMOVAL" +); + +$SAVE_DIR = dirname(__FILE__); +$SOURCE_IMG = $SAVE_DIR . "/test.png"; + + foreach ($no_arg_filters as $filt) { + $im = imagecreatefrompng($SOURCE_IMG); + if (imagefilter($im, constant($filt))) { + imagepng($im, $SAVE_DIR."/".$filt. ".png"); + echo "$filt success\n"; + @unlink($SAVE_DIR."/".$filt. ".png"); + } else { + echo "$filt failed\n"; + } + } + + $im = imagecreatefrompng($SOURCE_IMG); + + if (imagefilter($im, IMG_FILTER_SMOOTH, -1924.124)) { + imagepng($im, $SAVE_DIR . "/IMG_FILTER_SMOOTH.png"); + echo "IMG_FILTER_SMOOTH success\n"; + @unlink($SAVE_DIR . "/IMG_FILTER_SMOOTH.png"); + } else { + echo "IMG_FILTER_SMOOTH failed\n"; + } + + $im = imagecreatefrompng($SOURCE_IMG); + + if (imagefilter($im, IMG_FILTER_COLORIZE, -127.12, -127.98, 127)) { + imagepng($im, $SAVE_DIR . "/IMG_FILTER_COLORIZE.png"); + echo "IMG_FILTER_COLORIZE success\n"; + unlink($SAVE_DIR . "/IMG_FILTER_COLORIZE.png"); + } else { + echo "IMG_FILTER_COLORIZE failed\n"; + } + + $im = imagecreatefrompng($SOURCE_IMG); + + if (imagefilter($im, IMG_FILTER_CONTRAST, -90)) { + imagepng($im, $SAVE_DIR . "/IMG_FILTER_CONTRAST.png"); + echo "IMG_FILTER_CONTRAST success\n"; + unlink($SAVE_DIR . "/IMG_FILTER_CONTRAST.png"); + } else { + echo "IMG_FILTER_CONTRAST failed\n"; + } + + $im = imagecreatefrompng($SOURCE_IMG); + + if (imagefilter($im, IMG_FILTER_BRIGHTNESS, 98)) { + imagepng($im, $SAVE_DIR . "/IMG_FILTER_BRIGHTNESS.png"); + echo "IMG_FILTER_BRIGHTNESS success\n"; + unlink($SAVE_DIR . "/IMG_FILTER_BRIGHTNESS.png"); + } else { + echo "IMG_FILTER_BRIGHTNESS failed\n"; + } + + $im = imagecreatefrompng($SOURCE_IMG); + + if (imagefilter($im, IMG_FILTER_PIXELATE, 5, true)) { + imagepng($im, $SAVE_DIR . "/IMG_FILTER_PIXELATE.png"); + echo "IMG_FILTER_PIXELATE success\n"; + unlink($SAVE_DIR . "/IMG_FILTER_PIXELATE.png"); + } else { + echo "IMG_FILTER_PIXELATE failed\n"; + } +?> +--EXPECT-- +IMG_FILTER_NEGATE success +IMG_FILTER_GRAYSCALE success +IMG_FILTER_EDGEDETECT success +IMG_FILTER_GAUSSIAN_BLUR success +IMG_FILTER_SELECTIVE_BLUR success +IMG_FILTER_EMBOSS success +IMG_FILTER_MEAN_REMOVAL success +IMG_FILTER_SMOOTH success +IMG_FILTER_COLORIZE success +IMG_FILTER_CONTRAST success +IMG_FILTER_BRIGHTNESS success +IMG_FILTER_PIXELATE success diff --git a/ext/gd/tests/imagefilter_error1.phpt b/ext/gd/tests/imagefilter_error1.phpt new file mode 100644 index 0000000..fb96ae3 --- /dev/null +++ b/ext/gd/tests/imagefilter_error1.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter passing in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +var_dump(imagefilter($image)); +?> +--EXPECTF-- +Warning: Wrong parameter count for imagefilter() in %s on line %d +NULL diff --git a/ext/gd/tests/imagefilter_error10.phpt b/ext/gd/tests/imagefilter_error10.phpt new file mode 100644 index 0000000..8b41211 --- /dev/null +++ b/ext/gd/tests/imagefilter_error10.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter resource of EMBOSS in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = tmpfile(); + +var_dump(imagefilter($image, IMG_FILTER_EMBOSS)); +?> +--EXPECTF-- +Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error11.phpt b/ext/gd/tests/imagefilter_error11.phpt new file mode 100644 index 0000000..9b1cf4d --- /dev/null +++ b/ext/gd/tests/imagefilter_error11.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter resource passing of EDGEDETECT in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = tmpfile(); + +var_dump(imagefilter($image, IMG_FILTER_EDGEDETECT)); +?> +--EXPECTF-- +Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error12.phpt b/ext/gd/tests/imagefilter_error12.phpt new file mode 100644 index 0000000..33fee28 --- /dev/null +++ b/ext/gd/tests/imagefilter_error12.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter resource of COLORIZE in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = tmpfile(); + +var_dump(imagefilter($image, IMG_FILTER_COLORIZE, 255, 255, 255)); +?> +--EXPECTF-- +Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error13.phpt b/ext/gd/tests/imagefilter_error13.phpt new file mode 100644 index 0000000..687d148 --- /dev/null +++ b/ext/gd/tests/imagefilter_error13.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing wrong parameter value of COLORIZE in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +var_dump(imagefilter($image, IMG_FILTER_COLORIZE, 800, 255, 255)); // Wrong value is truncated to 255 +?> +--EXPECTF-- +bool(true) diff --git a/ext/gd/tests/imagefilter_error14.phpt b/ext/gd/tests/imagefilter_error14.phpt new file mode 100644 index 0000000..6410395 --- /dev/null +++ b/ext/gd/tests/imagefilter_error14.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter type of COLORIZE in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +var_dump(imagefilter($image, IMG_FILTER_COLORIZE, 'wrong parameter', 255, 255)); +?> +--EXPECTF-- +Warning: imagefilter() expects parameter 3 to be long, %unicode_string_optional% given in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error15.phpt b/ext/gd/tests/imagefilter_error15.phpt new file mode 100644 index 0000000..87a412e --- /dev/null +++ b/ext/gd/tests/imagefilter_error15.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter resource of CONTRAST in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = tmpfile(); + +var_dump(imagefilter($image, IMG_FILTER_CONTRAST, 2)); +?> +--EXPECTF-- +Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error16.phpt b/ext/gd/tests/imagefilter_error16.phpt new file mode 100644 index 0000000..2a84c2f --- /dev/null +++ b/ext/gd/tests/imagefilter_error16.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter type of CONTRAST in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +var_dump(imagefilter($image, IMG_FILTER_CONTRAST, 'wrong parameter')); +?> +--EXPECTF-- +Warning: imagefilter() expects parameter 3 to be long, %unicode_string_optional% given in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error17.phpt b/ext/gd/tests/imagefilter_error17.phpt new file mode 100644 index 0000000..adafc3e --- /dev/null +++ b/ext/gd/tests/imagefilter_error17.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter resource of GRAYSCALE in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = tmpfile(); + +var_dump(imagefilter($image, IMG_FILTER_GRAYSCALE)); +?> +--EXPECTF-- +Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error18.phpt b/ext/gd/tests/imagefilter_error18.phpt new file mode 100644 index 0000000..b636bfc --- /dev/null +++ b/ext/gd/tests/imagefilter_error18.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter resource of NEGATE in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = tmpfile(); + +var_dump(imagefilter($image, IMG_FILTER_NEGATE)); +?> +--EXPECTF-- +Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error19.phpt b/ext/gd/tests/imagefilter_error19.phpt new file mode 100644 index 0000000..e36b817 --- /dev/null +++ b/ext/gd/tests/imagefilter_error19.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter type of BRIGHTNESS in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +var_dump(imagefilter($image, IMG_FILTER_BRIGHTNESS, 'wrong parameter')); +?> +--EXPECTF-- +Warning: imagefilter() expects parameter 3 to be long, %unicode_string_optional% given in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error2.phpt b/ext/gd/tests/imagefilter_error2.phpt new file mode 100644 index 0000000..62ac662 --- /dev/null +++ b/ext/gd/tests/imagefilter_error2.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter passing in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +var_dump(imagefilter($image, 'wrong parameter')); +?> +--EXPECTF-- +Warning: imagefilter() expects parameter 2 to be long, %unicode_string_optional% given in %s on line %d +NULL diff --git a/ext/gd/tests/imagefilter_error20.phpt b/ext/gd/tests/imagefilter_error20.phpt new file mode 100644 index 0000000..f3db724 --- /dev/null +++ b/ext/gd/tests/imagefilter_error20.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter resource of BRIGHTNESS in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = tmpfile(); + +var_dump(imagefilter($image, IMG_FILTER_BRIGHTNESS, 1)); +?> +--EXPECTF-- +Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error3.phpt b/ext/gd/tests/imagefilter_error3.phpt new file mode 100644 index 0000000..67f6c19 --- /dev/null +++ b/ext/gd/tests/imagefilter_error3.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter passing of PIXELATE in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +var_dump(imagefilter($image, IMG_FILTER_PIXELATE, 'wrong parameter')); +?> +--EXPECTF-- +Warning: imagefilter() expects parameter 3 to be long, %unicode_string_optional% given in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error4.phpt b/ext/gd/tests/imagefilter_error4.phpt new file mode 100644 index 0000000..babb37e --- /dev/null +++ b/ext/gd/tests/imagefilter_error4.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter resource of PIXELATE in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = tmpfile(); + +var_dump(imagefilter($image, IMG_FILTER_PIXELATE, 3)); +?> +--EXPECTF-- +Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error5.phpt b/ext/gd/tests/imagefilter_error5.phpt new file mode 100644 index 0000000..a7d9443 --- /dev/null +++ b/ext/gd/tests/imagefilter_error5.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter passing of SMOOTH in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +var_dump(imagefilter($image, IMG_FILTER_SMOOTH, 'wrong parameter')); +?> +--EXPECTF-- +Warning: imagefilter() expects parameter 3 to be double, %unicode_string_optional% given in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error6.phpt b/ext/gd/tests/imagefilter_error6.phpt new file mode 100644 index 0000000..05dd187 --- /dev/null +++ b/ext/gd/tests/imagefilter_error6.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter resource of SMOOTH in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = tmpfile(); + +var_dump(imagefilter($image, IMG_FILTER_SMOOTH, 3.0)); +?> +--EXPECTF-- +Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error7.phpt b/ext/gd/tests/imagefilter_error7.phpt new file mode 100644 index 0000000..6c08e5a --- /dev/null +++ b/ext/gd/tests/imagefilter_error7.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter resource of MEAN_REMOVAL in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = tmpfile(); + +var_dump(imagefilter($image, IMG_FILTER_MEAN_REMOVAL)); +?> +--EXPECTF-- +Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error8.phpt b/ext/gd/tests/imagefilter_error8.phpt new file mode 100644 index 0000000..57c3168 --- /dev/null +++ b/ext/gd/tests/imagefilter_error8.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter resource of SELECTIVE_BLUR in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = tmpfile(); + +var_dump(imagefilter($image, IMG_FILTER_SELECTIVE_BLUR)); +?> +--EXPECTF-- +Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefilter_error9.phpt b/ext/gd/tests/imagefilter_error9.phpt new file mode 100644 index 0000000..a74ea64 --- /dev/null +++ b/ext/gd/tests/imagefilter_error9.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing wrong parameter resource of GAUSSIAN_BLUR in imagefilter() of GD library +--CREDITS-- +Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = tmpfile(); + +var_dump(imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR)); +?> +--EXPECTF-- +Warning: imagefilter(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imagefontheight_basic.phpt b/ext/gd/tests/imagefontheight_basic.phpt new file mode 100644 index 0000000..bfcd0bb --- /dev/null +++ b/ext/gd/tests/imagefontheight_basic.phpt @@ -0,0 +1,19 @@ +--TEST-- +Testing imagefontheight() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +var_dump(imagefontheight(1),imagefontheight(2),imagefontheight(3),imagefontheight(4),imagefontheight(5)); +?> +--EXPECT-- +int(8) +int(13) +int(13) +int(16) +int(15) diff --git a/ext/gd/tests/imagefontheight_error1.phpt b/ext/gd/tests/imagefontheight_error1.phpt new file mode 100644 index 0000000..88d1771 --- /dev/null +++ b/ext/gd/tests/imagefontheight_error1.phpt @@ -0,0 +1,15 @@ +--TEST-- +Testing error on string parameter for imagefontheight() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +imagefontheight('string'); +?> +--EXPECTF-- +Warning: imagefontheight() expects parameter 1 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagefontwidth_basic.phpt b/ext/gd/tests/imagefontwidth_basic.phpt new file mode 100644 index 0000000..0a9df52 --- /dev/null +++ b/ext/gd/tests/imagefontwidth_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing imagefontwidth() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +var_dump(imagefontwidth(1),imagefontwidth(2),imagefontwidth(3),imagefontwidth(4),imagefontwidth(5)); +var_dump(imagefontwidth(1) < imagefontwidth(5)); +?> +--EXPECT-- +int(5) +int(6) +int(7) +int(8) +int(9) +bool(true) diff --git a/ext/gd/tests/imagefontwidth_error1.phpt b/ext/gd/tests/imagefontwidth_error1.phpt new file mode 100644 index 0000000..dd80034 --- /dev/null +++ b/ext/gd/tests/imagefontwidth_error1.phpt @@ -0,0 +1,15 @@ +--TEST-- +Testing error on string parameter for imagefontwidth() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +imagefontwidth('string'); +?> +--EXPECTF-- +Warning: imagefontwidth() expects parameter 1 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagefttext.phpt b/ext/gd/tests/imagefttext.phpt new file mode 100644 index 0000000..16e0495 --- /dev/null +++ b/ext/gd/tests/imagefttext.phpt @@ -0,0 +1,52 @@ +--TEST-- +imagefttext() function test +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + if (!function_exists("imagefttext")) { + die("skip imagefttext() not available."); + } +?> +--FILE-- +<?php + $cwd = dirname(__FILE__); + $fontfile_8859 = "$cwd/test8859.ttf"; + + function testrun($im, $fontfile) { + $sx = imagesx($im); + $sy = imagesy($im); + + $colour_w = imagecolorallocate($im, 255, 255, 255); + $colour_b = imagecolorallocate($im, 0, 0, 0); + + imagefilledrectangle($im, 0, 0, $sx - 1, $sy - 1, $colour_b); + imagefttext($im, $sy * 0.75, 0, 0, $sy - 1, $colour_w, $fontfile, "A", array()); + + $cnt = 0; + for ($y = 0; $y < $sy; ++$y) { + for ($x = 0; $x < $sx; ++$x) { + if (imagecolorat($im, $x, $y) == $colour_b) { + ++$cnt; + } + } + } + + // imagecolordeallocate($im, $colour_w); + // imagecolordeallocate($im, $colour_b); + + return ($cnt < ($sx * $sy)); + } + + $im = imagecreate(256, 256); + var_dump(testrun($im, $fontfile_8859)); + imagedestroy($im); + + $im = imagecreatetruecolor(256, 256); + var_dump(testrun($im, $fontfile_8859)); + imagedestroy($im); +?> +--EXPECT-- +bool(true) +bool(true) diff --git a/ext/gd/tests/imagegammacorrect_basic.phpt b/ext/gd/tests/imagegammacorrect_basic.phpt new file mode 100644 index 0000000..b568728 --- /dev/null +++ b/ext/gd/tests/imagegammacorrect_basic.phpt @@ -0,0 +1,32 @@ +--TEST-- +Testing imagegammacorrect() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(150, 150); + +$grey = imagecolorallocate($image,6,6,6); +$gray = imagecolorallocate($image,15,15,15); + +$half = imagefilledarc ( $image, 75, 75, 70, 70, 0, 180, $grey, IMG_ARC_PIE ); +$half2 = imagefilledarc ( $image, 75, 75, 70, 70, 0, -180, $gray, IMG_ARC_PIE ); + +$gamma = imagegammacorrect($image, 1, 5); + +if ($gamma){ + ob_start(); + imagepng($image, null, 9); + $img = ob_get_contents(); + ob_end_clean(); +} + +echo md5(base64_encode($img)); +?> +--EXPECT-- +30639772903913594bc665743e1b9ab8 diff --git a/ext/gd/tests/imagegammacorrect_error1.phpt b/ext/gd/tests/imagegammacorrect_error1.phpt new file mode 100644 index 0000000..fdcdec8 --- /dev/null +++ b/ext/gd/tests/imagegammacorrect_error1.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error with non-resource paramenter of imagegammacorrect() of GD library, +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$gamma = imagegammacorrect('string', 1, 5); + +?> +--EXPECTF-- +Warning: imagegammacorrect() expects parameter 1 to be resource, %s given in %s on line %d diff --git a/ext/gd/tests/imagegammacorrect_error2.phpt b/ext/gd/tests/imagegammacorrect_error2.phpt new file mode 100644 index 0000000..604d7da --- /dev/null +++ b/ext/gd/tests/imagegammacorrect_error2.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error with non-Image resource paramenter of imagegammacorrect() of GD library, +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = tmpfile(); +$gamma = imagegammacorrect($image, 1, 5); + +?> +--EXPECTF-- +Warning: imagegammacorrect(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagegammacorrect_error3.phpt b/ext/gd/tests/imagegammacorrect_error3.phpt new file mode 100644 index 0000000..fd680aa --- /dev/null +++ b/ext/gd/tests/imagegammacorrect_error3.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error with non-double first paramenter of imagegammacorrect() of GD library, +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$gamma = imagegammacorrect($image, 'string', 5); + +?> +--EXPECTF-- +Warning: imagegammacorrect() expects parameter 2 to be double, %s given in %s on line %d diff --git a/ext/gd/tests/imagegammacorrect_error4.phpt b/ext/gd/tests/imagegammacorrect_error4.phpt new file mode 100644 index 0000000..5476d4c --- /dev/null +++ b/ext/gd/tests/imagegammacorrect_error4.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error with non-double second paramenter of imagegammacorrect() of GD library, +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$gamma = imagegammacorrect($image, 1, 'string'); + +?> +--EXPECTF-- +Warning: imagegammacorrect() expects parameter 3 to be double, %s given in %s on line %d diff --git a/ext/gd/tests/imagegammacorrect_variation1.phpt b/ext/gd/tests/imagegammacorrect_variation1.phpt new file mode 100644 index 0000000..cda96c6 --- /dev/null +++ b/ext/gd/tests/imagegammacorrect_variation1.phpt @@ -0,0 +1,32 @@ +--TEST-- +Testing imagegammacorrect() of GD library with non TrueColor image +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreate(150, 150); + +$grey = imagecolorallocate($image,6,6,6); +$gray = imagecolorallocate($image,15,15,15); + +$half = imagefilledarc ( $image, 75, 75, 70, 70, 0, 180, $grey, IMG_ARC_PIE ); +$half2 = imagefilledarc ( $image, 75, 75, 70, 70, 0, -180, $gray, IMG_ARC_PIE ); + +$gamma = imagegammacorrect($image, 1, 5); + +if ($gamma){ + ob_start(); + imagepng($image, null, 9); + $img = ob_get_contents(); + ob_end_clean(); +} + +echo md5(base64_encode($img)); +?> +--EXPECT-- +7716c0905ae08bd84b4d6cba8969a42e diff --git a/ext/gd/tests/imageinterlace_basic.phpt b/ext/gd/tests/imageinterlace_basic.phpt new file mode 100644 index 0000000..657b256 --- /dev/null +++ b/ext/gd/tests/imageinterlace_basic.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing imageinterlace() of GD library +--CREDITS-- +Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(100, 100); +var_dump(imageinterlace($image)); +?> +--EXPECT-- +int(0) diff --git a/ext/gd/tests/imageinterlace_error1.phpt b/ext/gd/tests/imageinterlace_error1.phpt new file mode 100644 index 0000000..5c871e7 --- /dev/null +++ b/ext/gd/tests/imageinterlace_error1.phpt @@ -0,0 +1,20 @@ +--TEST-- +Testing passing no parameters to imageinterlace() of GD library +--CREDITS-- +Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(100, 100); + +//calling with no parameters +var_dump(imageinterlace()); +?> +--EXPECTF-- +Warning: imageinterlace() expects at least 1 parameter, 0 given in %s on line %d +NULL diff --git a/ext/gd/tests/imageinterlace_error2.phpt b/ext/gd/tests/imageinterlace_error2.phpt new file mode 100644 index 0000000..808c88a --- /dev/null +++ b/ext/gd/tests/imageinterlace_error2.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing resource that is not a image to imageinterlace() of GD library +--CREDITS-- +Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = fopen('php://stdin', 'r'); +var_dump(imageinterlace($image)); +?> +--EXPECTF-- +Warning: imageinterlace(): supplied resource is not a valid Image resource in %s on line %d +bool(false) diff --git a/ext/gd/tests/imageinterlace_variation1.phpt b/ext/gd/tests/imageinterlace_variation1.phpt new file mode 100644 index 0000000..2c224ef --- /dev/null +++ b/ext/gd/tests/imageinterlace_variation1.phpt @@ -0,0 +1,20 @@ +--TEST-- +Testing setting the interlace bit on with imageinterlace() of GD library +--CREDITS-- +Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(100, 100); + +var_dump(imageinterlace($image, 1)); +var_dump(imageinterlace($image)); +?> +--EXPECT-- +int(1) +int(1) diff --git a/ext/gd/tests/imageinterlace_variation2.phpt b/ext/gd/tests/imageinterlace_variation2.phpt new file mode 100644 index 0000000..b4735dc --- /dev/null +++ b/ext/gd/tests/imageinterlace_variation2.phpt @@ -0,0 +1,24 @@ +--TEST-- +Testing setting the interlace bit off with imageinterlace() of GD library +--CREDITS-- +Edgar Ferreira da Silva <contato [at] edgarfs [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$image = imagecreatetruecolor(100, 100); + +//setting the interlace bit to on +imageinterlace($image, 1); + +//setting de interlace bit to off +var_dump(imageinterlace($image, 0)); +var_dump(imageinterlace($image)); +?> +--EXPECT-- +int(0) +int(0) diff --git a/ext/gd/tests/imageistruecolor_basic.phpt b/ext/gd/tests/imageistruecolor_basic.phpt new file mode 100644 index 0000000..a78aaa4 --- /dev/null +++ b/ext/gd/tests/imageistruecolor_basic.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing imageistruecolor() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +var_dump(imageistruecolor($image)); +?> +--EXPECT-- +bool(true)
\ No newline at end of file diff --git a/ext/gd/tests/imageistruecolor_error1.phpt b/ext/gd/tests/imageistruecolor_error1.phpt new file mode 100644 index 0000000..06453b7 --- /dev/null +++ b/ext/gd/tests/imageistruecolor_error1.phpt @@ -0,0 +1,24 @@ +--TEST-- +Testing imageistruecolor(): wrong parameters +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$resource = tmpfile(); + +imageistruecolor('string'); +imageistruecolor($resource); +imageistruecolor(array()); +?> +--EXPECTF-- +Warning: imageistruecolor() expects parameter 1 to be resource, string given in %s on line %d + +Warning: imageistruecolor(): supplied resource is not a valid Image resource in %s on line %d + +Warning: imageistruecolor() expects parameter 1 to be resource, array given in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagelayereffect_basic.phpt b/ext/gd/tests/imagelayereffect_basic.phpt new file mode 100644 index 0000000..a34e05e --- /dev/null +++ b/ext/gd/tests/imagelayereffect_basic.phpt @@ -0,0 +1,27 @@ +--TEST-- +Testing imagelayereffect() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!GD_BUNDLED) die('skip function only available in bundled, external GD detected'); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +$layer = imagelayereffect($image, IMG_EFFECT_REPLACE); + +if ($layer){ + ob_start(); + imagepng($image, null, 9); + $img = ob_get_contents(); + ob_end_clean(); +} + +echo md5(base64_encode($img)); +?> +--EXPECT-- +5a8fe9864cbd20e5dbe730c77f30db95 diff --git a/ext/gd/tests/imagelayereffect_error1.phpt b/ext/gd/tests/imagelayereffect_error1.phpt new file mode 100644 index 0000000..21f37a8 --- /dev/null +++ b/ext/gd/tests/imagelayereffect_error1.phpt @@ -0,0 +1,16 @@ +--TEST-- +Testing imagelayereffect() with invalid resource of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!GD_BUNDLED) die('skip function only available in bundled, external GD detected'); +?> +--FILE-- +<?php +$layer = imagelayereffect('invalid_resource', IMG_EFFECT_REPLACE); +?> +--EXPECTF-- +Warning: imagelayereffect() expects parameter 1 to be resource, %s given in %s on line %d diff --git a/ext/gd/tests/imagelayereffect_error2.phpt b/ext/gd/tests/imagelayereffect_error2.phpt new file mode 100644 index 0000000..d8d331b --- /dev/null +++ b/ext/gd/tests/imagelayereffect_error2.phpt @@ -0,0 +1,18 @@ +--TEST-- +Testing imagelayereffect() wth invalid effect of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!GD_BUNDLED) die('skip function only available in bundled, external GD detected'); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); + +$layer = imagelayereffect($image, 'IMG_EFFECT_REPLACE'); +?> +--EXPECTF-- +Warning: imagelayereffect() expects parameter 2 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagelayereffect_error3.phpt b/ext/gd/tests/imagelayereffect_error3.phpt new file mode 100644 index 0000000..d4deff1 --- /dev/null +++ b/ext/gd/tests/imagelayereffect_error3.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing imagelayereffect() with invalid resource of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!GD_BUNDLED) die('skip function only available in bundled, external GD detected'); +?> +--FILE-- +<?php +$resource = tmpfile(); +$layer = imagelayereffect($resource, IMG_EFFECT_REPLACE); +?> +--EXPECTF-- +Warning: imagelayereffect(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imageloadfont_error1.phpt b/ext/gd/tests/imageloadfont_error1.phpt new file mode 100644 index 0000000..16d1a3c --- /dev/null +++ b/ext/gd/tests/imageloadfont_error1.phpt @@ -0,0 +1,15 @@ +--TEST-- +Testing that imageloadfont() breaks on non-string first parameter +--CREDITS-- +Neveo Harrison <neveoo [at] gmail [dot] com> #testfest #tek11 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +var_dump( imageloadfont(array()) ); +?> +--EXPECTF-- +Warning: imageloadfont() expects parameter 1 to be string, array given in %s on line %d +NULL
\ No newline at end of file diff --git a/ext/gd/tests/imageloadfont_error2.phpt b/ext/gd/tests/imageloadfont_error2.phpt new file mode 100644 index 0000000..459cb71 --- /dev/null +++ b/ext/gd/tests/imageloadfont_error2.phpt @@ -0,0 +1,15 @@ +--TEST-- +Testing that imageloadfont() breaks on invalid file passed as first argument +--CREDITS-- +Austin Drouare <austin.drouare [at] gmail [dot] com> #testfest #tek11 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +var_dump( imageloadfont('\src\invalidfile.font') ); +?> +--EXPECTF-- +Warning: imageloadfont(\src\invalidfile.font): failed to open stream: No such file or directory in %s on line %d +bool(false) diff --git a/ext/gd/tests/imageloadfont_invalid.phpt b/ext/gd/tests/imageloadfont_invalid.phpt new file mode 100644 index 0000000..07bf150 --- /dev/null +++ b/ext/gd/tests/imageloadfont_invalid.phpt @@ -0,0 +1,26 @@ +--TEST-- +imageloadfont() function crashes +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die('skip external GD libraries always fail'); +?> +--FILE-- +<?php +$filename = dirname(__FILE__) . '/font.gdf'; +$bin = "\x41\x41\x41\x41\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00"; +$fp = fopen($filename, 'wb'); +fwrite($fp, $bin); +fclose($fp); + +$image = imagecreatetruecolor(50, 20); +$font = imageloadfont($filename); +$black = imagecolorallocate($image, 0, 0, 0); +imagestring($image, $font, 0, 0, "Hello", $black); +unlink($filename); +?> +--EXPECTF-- +Warning: imageloadfont(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully + in %simageloadfont_invalid.php on line %d + +Warning: imageloadfont(): Error reading font, invalid font header in %simageloadfont_invalid.php on line %d diff --git a/ext/gd/tests/imagepolygon_basic.phpt b/ext/gd/tests/imagepolygon_basic.phpt new file mode 100644 index 0000000..5c79cdf --- /dev/null +++ b/ext/gd/tests/imagepolygon_basic.phpt @@ -0,0 +1,80 @@ +--TEST-- +imageploygon() +--SKIPIF-- +<?php + if (!function_exists('imagepolygon')) die('skip imagepolygon() not available'); + require_once('skipif_imagetype.inc'); +?> +--FILE-- +<?php + +/* Prototype : bool imagepolygon ( resource $image , array $points , int $num_points , int $color ) + * Description: Draws a polygon. + * Source code: ext/standard/image.c + * Alias to functions: + */ + + +echo "Simple test of imagepolygon() function\n"; + +$dest = dirname(realpath(__FILE__)) . '/imagepolygon.png'; + +// create a blank image +$image = imagecreatetruecolor(400, 300); + +// set the background color to black +$bg = imagecolorallocate($image, 0, 0, 0); + +// draw a red polygon +$col_poly = imagecolorallocate($image, 255, 0, 0); + +// draw the polygon +imagepolygon($image, array ( + 0, 0, + 100, 200, + 300, 200 + ), + 3, + $col_poly); + +// output the picture to a file +imagepng($image, $dest); + +$col1 = imagecolorat($image, 100, 200); +$col2 = imagecolorat($image, 100, 100); +$color1 = imagecolorsforindex($image, $col1); +$color2 = imagecolorsforindex($image, $col2); +var_dump($color1, $color2); + +imagedestroy($image); + +echo "Done\n"; +?> +--CLEAN-- +<?php + $dest = dirname(realpath(__FILE__)) . '/imagepolygon.png'; + @unlink($dest); +?> +--EXPECT-- +Simple test of imagepolygon() function +array(4) { + ["red"]=> + int(255) + ["green"]=> + int(0) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +array(4) { + ["red"]=> + int(0) + ["green"]=> + int(0) + ["blue"]=> + int(0) + ["alpha"]=> + int(0) +} +Done diff --git a/ext/gd/tests/imagepolygon_negative.phpt b/ext/gd/tests/imagepolygon_negative.phpt new file mode 100644 index 0000000..bb9010c --- /dev/null +++ b/ext/gd/tests/imagepolygon_negative.phpt @@ -0,0 +1,15 @@ +--TEST-- +imagepolygon() with a negative num of points +--SKIPIF-- +<?php + if (!function_exists('imagepolygon')) die('skip imagepolygon() not available'); +?> +--FILE-- +<?php +$im = imagecreate(100, 100); +$black = imagecolorallocate($im, 0, 0, 0); +if (imagepolygon($im, array(0, 0, 0, 0, 0, 0), -1, $black)) echo "should be false"; +imagedestroy($im); +?> +--EXPECTF-- +Warning: imagepolygon(): You must give a positive number of points in %s on line %d diff --git a/ext/gd/tests/imagerectangle_basic.phpt b/ext/gd/tests/imagerectangle_basic.phpt new file mode 100644 index 0000000..f706ee7 --- /dev/null +++ b/ext/gd/tests/imagerectangle_basic.phpt @@ -0,0 +1,27 @@ +--TEST--
+Testing imagerectangle() of GD library
+--CREDITS--
+Ivan Rosolen <contato [at] ivanrosolen [dot] com>
+#testfest PHPSP on 2009-06-30
+--SKIPIF--
+<?php
+if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' );
+?>
+--FILE--
+<?php
+// Create a image
+$image = imagecreatetruecolor( 100, 100 );
+
+// Draw a rectangle
+imagerectangle( $image, 0, 0, 50, 50, imagecolorallocate($image, 255, 255, 255) );
+
+ob_start();
+imagepng( $image, null, 9 );
+$img = ob_get_contents();
+ob_end_clean();
+
+echo md5(base64_encode($img));
+
+?>
+--EXPECT--
+282aaecfdd50091821d63093d9bb1bb9
\ No newline at end of file diff --git a/ext/gd/tests/imagerectangle_error1.phpt b/ext/gd/tests/imagerectangle_error1.phpt new file mode 100644 index 0000000..2b4235e --- /dev/null +++ b/ext/gd/tests/imagerectangle_error1.phpt @@ -0,0 +1,19 @@ +--TEST--
+Testing wrong param passing imagerectangle() of GD library
+--CREDITS--
+Ivan Rosolen <contato [at] ivanrosolen [dot] com>
+#testfest PHPSP on 2009-06-30
+--SKIPIF--
+<?php
+if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' );
+?>
+--FILE--
+<?php
+// Create a image
+$image = imagecreatetruecolor( 100, 100 );
+
+// Draw a rectangle
+imagerectangle( 'wrong param', 0, 0, 50, 50, imagecolorallocate($image, 255, 255, 255) );
+?>
+--EXPECTF--
+Warning: imagerectangle() expects parameter 1 to be resource, %s given in %s on line %d diff --git a/ext/gd/tests/imagerectangle_error2.phpt b/ext/gd/tests/imagerectangle_error2.phpt new file mode 100644 index 0000000..5fc1914 --- /dev/null +++ b/ext/gd/tests/imagerectangle_error2.phpt @@ -0,0 +1,19 @@ +--TEST--
+Testing wrong param passing imagerectangle() of GD library
+--CREDITS--
+Ivan Rosolen <contato [at] ivanrosolen [dot] com>
+#testfest PHPSP on 2009-06-30
+--SKIPIF--
+<?php
+if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' );
+?>
+--FILE--
+<?php
+// Create a resource
+$image = tmpfile();
+
+// Draw a rectangle
+imagerectangle( $image, 0, 0, 50, 50, 2 );
+?>
+--EXPECTF--
+Warning: imagerectangle(): supplied resource is not a valid Image resource in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagerectangle_error3.phpt b/ext/gd/tests/imagerectangle_error3.phpt new file mode 100644 index 0000000..d5dd4c1 --- /dev/null +++ b/ext/gd/tests/imagerectangle_error3.phpt @@ -0,0 +1,19 @@ +--TEST--
+Testing wrong param passing imagerectangle() of GD library
+--CREDITS--
+Ivan Rosolen <contato [at] ivanrosolen [dot] com>
+#testfest PHPSP on 2009-06-30
+--SKIPIF--
+<?php
+if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' );
+?>
+--FILE--
+<?php
+// Create a image
+$image = imagecreatetruecolor( 100, 100 );
+
+// Draw a rectangle
+imagerectangle( $image, 'wrong param', 0, 50, 50, imagecolorallocate($image, 255, 255, 255) );
+?>
+--EXPECTF--
+Warning: imagerectangle() expects parameter 2 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagerectangle_error4.phpt b/ext/gd/tests/imagerectangle_error4.phpt new file mode 100644 index 0000000..7ecc416 --- /dev/null +++ b/ext/gd/tests/imagerectangle_error4.phpt @@ -0,0 +1,19 @@ +--TEST--
+Testing wrong param passing imagerectangle() of GD library
+--CREDITS--
+Ivan Rosolen <contato [at] ivanrosolen [dot] com>
+#testfest PHPSP on 2009-06-30
+--SKIPIF--
+<?php
+if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' );
+?>
+--FILE--
+<?php
+// Create a image
+$image = imagecreatetruecolor( 100, 100 );
+
+// Draw a rectangle
+imagerectangle( $image, 0, 'wrong param', 50, 50, imagecolorallocate($image, 255, 255, 255) );
+?>
+--EXPECTF--
+Warning: imagerectangle() expects parameter 3 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagerectangle_error5.phpt b/ext/gd/tests/imagerectangle_error5.phpt new file mode 100644 index 0000000..b4288d2 --- /dev/null +++ b/ext/gd/tests/imagerectangle_error5.phpt @@ -0,0 +1,19 @@ +--TEST--
+Testing wrong param passing imagerectangle() of GD library
+--CREDITS--
+Ivan Rosolen <contato [at] ivanrosolen [dot] com>
+#testfest PHPSP on 2009-06-30
+--SKIPIF--
+<?php
+if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' );
+?>
+--FILE--
+<?php
+// Create a image
+$image = imagecreatetruecolor( 100, 100 );
+
+// Draw a rectangle
+imagerectangle( $image, 0, 0, 'wrong param', 50, imagecolorallocate($image, 255, 255, 255) );
+?>
+--EXPECTF--
+Warning: imagerectangle() expects parameter 4 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagerectangle_error6.phpt b/ext/gd/tests/imagerectangle_error6.phpt new file mode 100644 index 0000000..aab378e --- /dev/null +++ b/ext/gd/tests/imagerectangle_error6.phpt @@ -0,0 +1,19 @@ +--TEST--
+Testing wrong param passing imagerectangle() of GD library
+--CREDITS--
+Ivan Rosolen <contato [at] ivanrosolen [dot] com>
+#testfest PHPSP on 2009-06-30
+--SKIPIF--
+<?php
+if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' );
+?>
+--FILE--
+<?php
+// Create a image
+$image = imagecreatetruecolor( 100, 100 );
+
+// Draw a rectangle
+imagerectangle( $image, 0, 0, 50, 'wrong param', imagecolorallocate($image, 255, 255, 255) );
+?>
+--EXPECTF--
+Warning: imagerectangle() expects parameter 5 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagerectangle_error7.phpt b/ext/gd/tests/imagerectangle_error7.phpt new file mode 100644 index 0000000..f6ed778 --- /dev/null +++ b/ext/gd/tests/imagerectangle_error7.phpt @@ -0,0 +1,19 @@ +--TEST--
+Testing wrong param passing imagerectangle() of GD library
+--CREDITS--
+Ivan Rosolen <contato [at] ivanrosolen [dot] com>
+#testfest PHPSP on 2009-06-30
+--SKIPIF--
+<?php
+if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' );
+?>
+--FILE--
+<?php
+// Create a image
+$image = imagecreatetruecolor( 100, 100 );
+
+// Draw a rectangle
+imagerectangle( $image, 0, 0, 50, 50, 'wrong param' );
+?>
+--EXPECTF--
+Warning: imagerectangle() expects parameter 6 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagerectangle_error8.phpt b/ext/gd/tests/imagerectangle_error8.phpt new file mode 100644 index 0000000..361de69 --- /dev/null +++ b/ext/gd/tests/imagerectangle_error8.phpt @@ -0,0 +1,19 @@ +--TEST--
+Testing wrong param passing imagerectangle() of GD library
+--CREDITS--
+Ivan Rosolen <contato [at] ivanrosolen [dot] com>
+#testfest PHPSP on 2009-06-30
+--SKIPIF--
+<?php
+if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' );
+?>
+--FILE--
+<?php
+// Create a image
+$image = imagecreatetruecolor( 100, 100 );
+
+// Draw a rectangle
+imagerectangle( $image, 0, 0, 50, 50 );
+?>
+--EXPECTF--
+Warning: imagerectangle() expects exactly 6 parameters, %d given in %s on line %d diff --git a/ext/gd/tests/imagerotate_overflow.phpt b/ext/gd/tests/imagerotate_overflow.phpt new file mode 100644 index 0000000..ade61d8 --- /dev/null +++ b/ext/gd/tests/imagerotate_overflow.phpt @@ -0,0 +1,32 @@ +--TEST-- +imagerotate() overflow with negative numbers +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + + if (!function_exists('imagerotate')) { + die("skip imagerotate() not available."); + } +?> +--FILE-- +<?php + +$im = imagecreate(10, 10); + +$tmp = imagerotate ($im, 5, -9999999); + +var_dump($tmp); + +if ($tmp) { + imagedestroy($tmp); +} + +if ($im) { + imagedestroy($im); +} + +?> +--EXPECT-- +bool(false) diff --git a/ext/gd/tests/imagesetbrush_basic.phpt b/ext/gd/tests/imagesetbrush_basic.phpt new file mode 100644 index 0000000..790184d --- /dev/null +++ b/ext/gd/tests/imagesetbrush_basic.phpt @@ -0,0 +1,37 @@ +--TEST-- +Test imagesetbrush() function : basic functionality +--CREDITS-- +Erick Belluci Tedeschi <erickbt86 [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if (!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +?> +--FILE-- +<?php +// Create the brush image +$img = imagecreate(10, 10); + +// Create the main image, 100x100 +$mainimg = imagecreatetruecolor(100, 100); + +$white = imagecolorallocate($img, 255, 0, 0); +imagefilledrectangle($img, 0, 0, 299, 99, $white); + +// Set the brush +imagesetbrush($mainimg, $img); + +// Draw a couple of brushes, each overlaying each +imageline($mainimg, 50, 50, 50, 60, IMG_COLOR_BRUSHED); + +// Get output and generate md5 hash +ob_start(); +imagepng($mainimg, null, 9); +$result_image = ob_get_contents(); +ob_end_clean(); +echo md5(base64_encode($result_image)); +?> +--EXPECT-- +8168577c0d1fe6d9d11397cb15263d82 diff --git a/ext/gd/tests/imagesetthickness_basic.phpt b/ext/gd/tests/imagesetthickness_basic.phpt new file mode 100644 index 0000000..a8b079b --- /dev/null +++ b/ext/gd/tests/imagesetthickness_basic.phpt @@ -0,0 +1,34 @@ +--TEST-- +Testing imagetruecolortopalette() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php +// Create a 200x100 image +$image = imagecreatetruecolor(200, 100); +$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); +$black = imagecolorallocate($image, 0x00, 0x00, 0x00); + +// Set the background to be white +imagefilledrectangle($image, 0, 0, 299, 99, $white); + +// Set the line thickness to 5 +imagesetthickness($image, 5); + +// Draw the rectangle +imagerectangle($image, 14, 14, 185, 85, $black); + +ob_start(); +imagepng($image, null, 9); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +93c3077f1bdc372cd0b0db96db282985
\ No newline at end of file diff --git a/ext/gd/tests/imagesetthickness_error1.phpt b/ext/gd/tests/imagesetthickness_error1.phpt new file mode 100644 index 0000000..0aed3a1 --- /dev/null +++ b/ext/gd/tests/imagesetthickness_error1.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing imagetruecolortopalette(): wrong types for first parameter +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$resource = tmpfile(); + +imagesetthickness('string', 5); +imagesetthickness(array(), 5); +imagesetthickness($resource, 5); +?> +--EXPECTF-- +Warning: imagesetthickness() expects parameter 1 to be resource, %s given in %s on line %d + +Warning: imagesetthickness() expects parameter 1 to be resource, array given in %s on line %d + +Warning: imagesetthickness(): supplied resource is not a valid Image resource in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagesetthickness_error2.phpt b/ext/gd/tests/imagesetthickness_error2.phpt new file mode 100644 index 0000000..4c8924e --- /dev/null +++ b/ext/gd/tests/imagesetthickness_error2.phpt @@ -0,0 +1,24 @@ +--TEST-- +Testing imagetruecolortopalette(): wrong types for second parameter +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(200, 100); + +imagesetthickness($image, 's'); +imagesetthickness($image, array()); +imagesetthickness($image, $image); + +?> +--EXPECTF-- +Warning: imagesetthickness() expects parameter 2 to be long, string given in %s on line %d + +Warning: imagesetthickness() expects parameter 2 to be long, array given in %s on line %d + +Warning: imagesetthickness() expects parameter 2 to be long, resource given in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagestring_basic.phpt b/ext/gd/tests/imagestring_basic.phpt new file mode 100644 index 0000000..adc68a6 --- /dev/null +++ b/ext/gd/tests/imagestring_basic.phpt @@ -0,0 +1,25 @@ +--TEST-- +Testing imagestring() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$white = imagecolorallocate($image, 255,255,255); + +$result = imagestring($image, 1, 5, 5, 'String Text', $white); + +ob_start(); +imagepng($image, null, 9); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +d0d2fe757400cb7846b36a8c34b41e4a diff --git a/ext/gd/tests/imagestring_error1.phpt b/ext/gd/tests/imagestring_error1.phpt new file mode 100644 index 0000000..b31f74e --- /dev/null +++ b/ext/gd/tests/imagestring_error1.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-resource parameter 1 of imagestring() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$result = imagestring('string', 1, 5, 5, 'String', 1); + +?> +--EXPECTF-- +Warning: imagestring() expects parameter 1 to be resource, %s given in %s on line %d diff --git a/ext/gd/tests/imagestring_error2.phpt b/ext/gd/tests/imagestring_error2.phpt new file mode 100644 index 0000000..d6146f7 --- /dev/null +++ b/ext/gd/tests/imagestring_error2.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-image resource parameter 1 of imagestring() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$result = imagestring(tmpfile(), 1, 5, 5, 'String', 1); + +?> +--EXPECTF-- +Warning: imagestring(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagestring_error3.phpt b/ext/gd/tests/imagestring_error3.phpt new file mode 100644 index 0000000..d9a9e47 --- /dev/null +++ b/ext/gd/tests/imagestring_error3.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 2 of imagestring() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagestring($image, 'string', 5, 5, 'String', 1); + +?> +--EXPECTF-- +Warning: imagestring() expects parameter 2 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagestring_error4.phpt b/ext/gd/tests/imagestring_error4.phpt new file mode 100644 index 0000000..40330b1 --- /dev/null +++ b/ext/gd/tests/imagestring_error4.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 3 of imagestring() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagestring($image, 1, 'string', 5, 'String', 1); + +?> +--EXPECTF-- +Warning: imagestring() expects parameter 3 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagestring_error5.phpt b/ext/gd/tests/imagestring_error5.phpt new file mode 100644 index 0000000..6f45c55 --- /dev/null +++ b/ext/gd/tests/imagestring_error5.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 4 of imagestring() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagestring($image, 1, 5, 'string', 'String', 1); + +?> +--EXPECTF-- +Warning: imagestring() expects parameter 4 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagestring_error6.phpt b/ext/gd/tests/imagestring_error6.phpt new file mode 100644 index 0000000..29bc79d --- /dev/null +++ b/ext/gd/tests/imagestring_error6.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-string parameter 5 of imagestring() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagestring($image, 1, 5, 5, $image, 1); + +?> +--EXPECTF-- +Warning: imagestring() expects parameter 5 to be string%S, %s given in %s on line %d diff --git a/ext/gd/tests/imagestring_error7.phpt b/ext/gd/tests/imagestring_error7.phpt new file mode 100644 index 0000000..75ab2f6 --- /dev/null +++ b/ext/gd/tests/imagestring_error7.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 6 of imagestring() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagestring($image, 1, 5, 5, 'String', 'font'); + +?> +--EXPECTF-- +Warning: imagestring() expects parameter 6 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagestringup_basic.phpt b/ext/gd/tests/imagestringup_basic.phpt new file mode 100644 index 0000000..0c748b6 --- /dev/null +++ b/ext/gd/tests/imagestringup_basic.phpt @@ -0,0 +1,25 @@ +--TEST-- +Testing imagestringup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$white = imagecolorallocate($image, 255,255,255); + +$result = imagestringup($image, 1, 5, 25, 'Str', $white); + +ob_start(); +imagepng($image, null, 9); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +7c28016adcf620b772af2a8655b87bd2 diff --git a/ext/gd/tests/imagestringup_error1.phpt b/ext/gd/tests/imagestringup_error1.phpt new file mode 100644 index 0000000..1447727 --- /dev/null +++ b/ext/gd/tests/imagestringup_error1.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-resource parameter 1 of imagestringup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$result = imagestringup('string', 1, 5, 5, 'String', 1); + +?> +--EXPECTF-- +Warning: imagestringup() expects parameter 1 to be resource, %s given in %s on line %d diff --git a/ext/gd/tests/imagestringup_error2.phpt b/ext/gd/tests/imagestringup_error2.phpt new file mode 100644 index 0000000..d1d5aa2 --- /dev/null +++ b/ext/gd/tests/imagestringup_error2.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-image resource parameter 1 of imagestringup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php + +$result = imagestringup(tmpfile(), 1, 5, 5, 'String', 1); + +?> +--EXPECTF-- +Warning: imagestringup(): supplied resource is not a valid Image resource in %s on line %d diff --git a/ext/gd/tests/imagestringup_error3.phpt b/ext/gd/tests/imagestringup_error3.phpt new file mode 100644 index 0000000..27e9007 --- /dev/null +++ b/ext/gd/tests/imagestringup_error3.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 2 of imagestringup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagestringup($image, 'string', 5, 5, 'String', 1); + +?> +--EXPECTF-- +Warning: imagestringup() expects parameter 2 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagestringup_error4.phpt b/ext/gd/tests/imagestringup_error4.phpt new file mode 100644 index 0000000..af2b8c0 --- /dev/null +++ b/ext/gd/tests/imagestringup_error4.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 3 of imagestringup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagestringup($image, 1, 'string', 5, 'String', 1); + +?> +--EXPECTF-- +Warning: imagestringup() expects parameter 3 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagestringup_error5.phpt b/ext/gd/tests/imagestringup_error5.phpt new file mode 100644 index 0000000..6f45c55 --- /dev/null +++ b/ext/gd/tests/imagestringup_error5.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 4 of imagestring() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagestring($image, 1, 5, 'string', 'String', 1); + +?> +--EXPECTF-- +Warning: imagestring() expects parameter 4 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagestringup_error6.phpt b/ext/gd/tests/imagestringup_error6.phpt new file mode 100644 index 0000000..ac6fe4a --- /dev/null +++ b/ext/gd/tests/imagestringup_error6.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-string parameter 5 of imagestringup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagestringup($image, 1, 5, 5, $image, 1); + +?> +--EXPECTF-- +Warning: imagestringup() expects parameter 5 to be string%S, %s given in %s on line %d diff --git a/ext/gd/tests/imagestringup_error7.phpt b/ext/gd/tests/imagestringup_error7.phpt new file mode 100644 index 0000000..396f2dd --- /dev/null +++ b/ext/gd/tests/imagestringup_error7.phpt @@ -0,0 +1,17 @@ +--TEST-- +Testing error on non-long parameter 6 of imagestringup() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(180, 30); +$result = imagestringup($image, 1, 5, 5, 'String', 'font'); + +?> +--EXPECTF-- +Warning: imagestringup() expects parameter 6 to be long, %s given in %s on line %d diff --git a/ext/gd/tests/imagetruecolortopalette_basic.phpt b/ext/gd/tests/imagetruecolortopalette_basic.phpt new file mode 100644 index 0000000..b0a0394 --- /dev/null +++ b/ext/gd/tests/imagetruecolortopalette_basic.phpt @@ -0,0 +1,31 @@ +--TEST-- +Testing imagetruecolortopalette() of GD library +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(150, 150); + +$a = imagecolorallocate($image,255,0,255); +$b = imagecolorallocate($image,0,255,255); + +$half = imagefilledarc ( $image, 75, 75, 70, 70, 0, 180, $a, IMG_ARC_PIE ); +$half2 = imagefilledarc ( $image, 75, 55, 80, 70, 0, -180, $b, IMG_ARC_PIE ); + +var_dump(imagetruecolortopalette($image, true, 2)); + +ob_start(); +imagepng($image, null, 9); +$img = ob_get_contents(); +ob_end_clean(); + +echo md5(base64_encode($img)); +?> +--EXPECT-- +bool(true) +0843f63ab2f9fddedd69b0b421686bc5
\ No newline at end of file diff --git a/ext/gd/tests/imagetruecolortopalette_error1.phpt b/ext/gd/tests/imagetruecolortopalette_error1.phpt new file mode 100644 index 0000000..ecafa15 --- /dev/null +++ b/ext/gd/tests/imagetruecolortopalette_error1.phpt @@ -0,0 +1,26 @@ +--TEST-- +Testing imagetruecolortopalette(): wrong parameters for parameter 1 +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php +$resource = tmpfile(); + +imagetruecolortopalette($resource, true, 2); +imagetruecolortopalette('string', true, 2); +imagetruecolortopalette(array(), true, 2); +imagetruecolortopalette(null, true, 2); +?> +--EXPECTF-- +Warning: imagetruecolortopalette(): supplied resource is not a valid Image resource in %s on line %d + +Warning: imagetruecolortopalette() expects parameter 1 to be resource, %s given in %s on line %d + +Warning: imagetruecolortopalette() expects parameter 1 to be resource, array given in %s on line %d + +Warning: imagetruecolortopalette() expects parameter 1 to be resource, null given in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagetruecolortopalette_error2.phpt b/ext/gd/tests/imagetruecolortopalette_error2.phpt new file mode 100644 index 0000000..cb7004c --- /dev/null +++ b/ext/gd/tests/imagetruecolortopalette_error2.phpt @@ -0,0 +1,22 @@ +--TEST-- +Testing imagetruecolortopalette(): wrong parameters for parameter 2 +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(50, 50); +$resource = tmpfile(); + +imagetruecolortopalette($image, $resource, 2); +imagetruecolortopalette($image, array(), 2); + +?> +--EXPECTF-- +Warning: imagetruecolortopalette() expects parameter 2 to be boolean, resource given in %s on line %d + +Warning: imagetruecolortopalette() expects parameter 2 to be boolean, array given in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagetruecolortopalette_error3.phpt b/ext/gd/tests/imagetruecolortopalette_error3.phpt new file mode 100644 index 0000000..d65a995 --- /dev/null +++ b/ext/gd/tests/imagetruecolortopalette_error3.phpt @@ -0,0 +1,28 @@ +--TEST-- +Testing imagetruecolortopalette(): wrong parameters for parameter 3 +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(50, 50); +$resource = tmpfile(); + +imagetruecolortopalette($image, true, 'string'); +imagetruecolortopalette($image, true, $resource); +imagetruecolortopalette($image, true, array()); +imagetruecolortopalette($image, true, null); + +?> +--EXPECTF-- +Warning: imagetruecolortopalette() expects parameter 3 to be long, string given in %s on line %d + +Warning: imagetruecolortopalette() expects parameter 3 to be long, resource given in %s on line %d + +Warning: imagetruecolortopalette() expects parameter 3 to be long, array given in %s on line %d + +Warning: imagetruecolortopalette(): Number of colors has to be greater than zero in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagetruecolortopalette_error4.phpt b/ext/gd/tests/imagetruecolortopalette_error4.phpt new file mode 100644 index 0000000..b9661e3 --- /dev/null +++ b/ext/gd/tests/imagetruecolortopalette_error4.phpt @@ -0,0 +1,21 @@ +--TEST-- +Testing imagetruecolortopalette(): out of range parameter 3 +--CREDITS-- +Rafael Dohms <rdohms [at] gmail [dot] com> +--SKIPIF-- +<?php + if (!extension_loaded("gd")) die("skip GD not present"); + if (!function_exists("imagecreatetruecolor")) die("skip GD Version not compatible"); +?> +--FILE-- +<?php +$image = imagecreatetruecolor(50, 50); + +imagetruecolortopalette($image, true, 0); +imagetruecolortopalette($image, true, -1); + +?> +--EXPECTF-- +Warning: imagetruecolortopalette(): Number of colors has to be greater than zero in %s on line %d + +Warning: imagetruecolortopalette(): Number of colors has to be greater than zero in %s on line %d
\ No newline at end of file diff --git a/ext/gd/tests/imagewbmp.phpt b/ext/gd/tests/imagewbmp.phpt new file mode 100644 index 0000000..a10dbdb --- /dev/null +++ b/ext/gd/tests/imagewbmp.phpt @@ -0,0 +1,30 @@ +--TEST-- +imagewbmp +--SKIPIF-- +<?php + if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$file = dirname(__FILE__) . '/im.wbmp'; + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); +imagesetpixel($im, 3,3, 0x0); +imagewbmp($im, $file); + +$im2 = imagecreatefromwbmp($file); +echo 'test create wbmp: '; +$c = imagecolorsforindex($im2, imagecolorat($im2, 3,3)); +$failed = false; +foreach ($c as $v) { + if ($v != 0) { + $failed = true; + } +} +echo !$failed ? 'ok' : 'failed'; +echo "\n"; +unlink($file); +?> +--EXPECT-- +test create wbmp: ok diff --git a/ext/gd/tests/jpeg2png.phpt b/ext/gd/tests/jpeg2png.phpt new file mode 100644 index 0000000..0a170ee --- /dev/null +++ b/ext/gd/tests/jpeg2png.phpt @@ -0,0 +1,45 @@ +--TEST-- +jpeg <--> png conversion test +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + + if (!function_exists("imagecreatefrompng") || !function_exists("imagepng")) { + die("skip png support unavailable"); + } + if (!function_exists("imagecreatefromjpeg") || !function_exists("imagejpeg")) { + die("skip jpeg support unavailable"); + } +?> +--FILE-- +<?php + $cwd = dirname(__FILE__); + + echo "PNG to JPEG conversion: "; + echo imagejpeg(imagecreatefrompng($cwd . "/conv_test.png"), $cwd . "/test_jpeg.jpeg") ? 'ok' : 'failed'; + echo "\n"; + + echo "Generated JPEG to PNG conversion: "; + echo imagepng(imagecreatefromjpeg($cwd . "/test_jpeg.jpeg"), $cwd . "/test_jpng.png") ? 'ok' : 'failed'; + echo "\n"; + + echo "JPEG to PNG conversion: "; + echo imagepng(imagecreatefromjpeg($cwd . "/conv_test.jpeg"), $cwd . "/test_png.png") ? 'ok' : 'failed'; + echo "\n"; + + echo "Generated PNG to JPEG conversion: "; + echo imagejpeg(imagecreatefrompng($cwd . "/test_png.png"), $cwd . "/test_pjpeg.jpeg") ? 'ok' : 'failed'; + echo "\n"; + + @unlink($cwd . "/test_jpeg.jpeg"); + @unlink($cwd . "/test_jpng.png"); + @unlink($cwd . "/test_png.png"); + @unlink($cwd . "/test_pjpeg.jpeg"); +?> +--EXPECT-- +PNG to JPEG conversion: ok +Generated JPEG to PNG conversion: ok +JPEG to PNG conversion: ok +Generated PNG to JPEG conversion: ok diff --git a/ext/gd/tests/jpeg2wbmp_error1.phpt b/ext/gd/tests/jpeg2wbmp_error1.phpt new file mode 100644 index 0000000..d0496cc --- /dev/null +++ b/ext/gd/tests/jpeg2wbmp_error1.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test jpeg2wbmp() function : wrong threshold value param +--CREDITS-- +Levi Fukumori <levi [at] fukumori [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('jpeg2wbmp')) { + die('skip jpeg2wbmp function is not available'); +} +?> +--FILE-- +<?php +// Create a blank image and add some text +$im = imagecreatetruecolor(120, 20); +$text_color = imagecolorallocate($im, 255, 255, 255); +imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); + +$file = dirname(__FILE__) .'/simpletext.jpg'; +$file2 = dirname(__FILE__) .'/simpletext.wbmp'; + +// Save the image as 'simpletext.jpg' +imagejpeg($im, $file); + +// Free up memory +imagedestroy($im); + +jpeg2wbmp($file, $file2, 20, 120, 9); +jpeg2wbmp($file, $file2, 20, 120, -1); +?> +--EXPECTF-- +Warning: jpeg2wbmp(): Invalid threshold value '9' in %s on line %d + +Warning: jpeg2wbmp(): Invalid threshold value '-1' in %s on line %d +--CLEAN-- +<?php +unlink(dirname(__FILE__) .'/simpletext.jpg'); +unlink(dirname(__FILE__) .'/simpletext.wbmp'); +?> diff --git a/ext/gd/tests/jpeg2wbmp_error2.phpt b/ext/gd/tests/jpeg2wbmp_error2.phpt new file mode 100644 index 0000000..692dcb8 --- /dev/null +++ b/ext/gd/tests/jpeg2wbmp_error2.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test jpeg2wbmp() function : wrong origin filename param +--CREDITS-- +Levi Fukumori <levi [at] fukumori [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('jpeg2wbmp')) { + die('skip jpeg2wbmp function is not available'); +} +?> +--FILE-- +<?php +$file = dirname(__FILE__) .'/simpletext.wbmp'; +jpeg2wbmp('', $file, 20, 120, 8); +jpeg2wbmp(null, $file, 20, 120, 8); +jpeg2wbmp(false, $file, 20, 120, 8); +?> +--EXPECTF-- +Warning: jpeg2wbmp(): Unable to open '' for reading in %s on line %d + +Warning: jpeg2wbmp(): Unable to open '' for reading in %s on line %d + +Warning: jpeg2wbmp(): Unable to open '' for reading in %s on line %d +--CLEAN-- +<?php +unlink(dirname(__FILE__) .'/simpletext.wbmp'); +?> diff --git a/ext/gd/tests/jpeg2wbmp_error3.phpt b/ext/gd/tests/jpeg2wbmp_error3.phpt new file mode 100644 index 0000000..df436c8 --- /dev/null +++ b/ext/gd/tests/jpeg2wbmp_error3.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test jpeg2wbmp() function : wrong destination filename param +--CREDITS-- +Levi Fukumori <levi [at] fukumori [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('jpeg2wbmp')) { + die('skip jpeg2wbmp function is not available'); +} +?> +--FILE-- +<?php +// Create a blank image and add some text +$im = imagecreatetruecolor(120, 20); +$text_color = imagecolorallocate($im, 255, 255, 255); +imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); + +$file = dirname(__FILE__) .'/simpletext.jpg'; + +// Save the image as 'simpletext.jpg' +imagejpeg($im, $file); + +// Free up memory +imagedestroy($im); + +jpeg2wbmp($file, '', 20, 120, 8); +jpeg2wbmp($file, null, 20, 120, 8); +jpeg2wbmp($file, false, 20, 120, 8); +?> +--EXPECTF-- +Warning: jpeg2wbmp(): Unable to open '' for writing in %s on line %d + +Warning: jpeg2wbmp(): Unable to open '' for writing in %s on line %d + +Warning: jpeg2wbmp(): Unable to open '' for writing in %s on line %d +--CLEAN-- +<?php +unlink(dirname(__FILE__) .'/simpletext.jpg'); +?> diff --git a/ext/gd/tests/jpg2gd.phpt b/ext/gd/tests/jpg2gd.phpt new file mode 100644 index 0000000..805ec79 --- /dev/null +++ b/ext/gd/tests/jpg2gd.phpt @@ -0,0 +1,42 @@ +--TEST-- +jpeg <--> gd1/gd2 conversion test +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + + if (!function_exists("imagecreatefromjpeg") || !function_exists("imagejpeg")) { + die("skip jpeg support unavailable"); + } +?> +--FILE-- +<?php + $cwd = dirname(__FILE__); + + echo "JPEG to GD1 conversion: "; + echo imagegd(imagecreatefromjpeg($cwd . "/conv_test.jpeg"), $cwd . "/test.gd1") ? 'ok' : 'failed'; + echo "\n"; + + echo "JPEG to GD2 conversion: "; + echo imagegd2(imagecreatefromjpeg($cwd . "/conv_test.jpeg"), $cwd . "/test.gd2") ? 'ok' : 'failed'; + echo "\n"; + + echo "GD1 to JPEG conversion: "; + echo imagejpeg(imagecreatefromgd($cwd . "/test.gd1"), $cwd . "/test_gd1.jpeg") ? 'ok' : 'failed'; + echo "\n"; + + echo "GD2 to JPEG conversion: "; + echo imagejpeg(imagecreatefromgd2($cwd . "/test.gd2"), $cwd . "/test_gd2.jpeg") ? 'ok' : 'failed'; + echo "\n"; + + @unlink($cwd . "/test.gd1"); + @unlink($cwd . "/test.gd2"); + @unlink($cwd . "/test_gd1.jpeg"); + @unlink($cwd . "/test_gd2.jpeg"); +?> +--EXPECT-- +JPEG to GD1 conversion: ok +JPEG to GD2 conversion: ok +GD1 to JPEG conversion: ok +GD2 to JPEG conversion: ok diff --git a/ext/gd/tests/libgd00086.phpt b/ext/gd/tests/libgd00086.phpt new file mode 100644 index 0000000..4c90934 --- /dev/null +++ b/ext/gd/tests/libgd00086.phpt @@ -0,0 +1,21 @@ +--TEST-- +libgd #86 (Possible infinite loop in imagecreatefrompng) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php + +$im = imagecreatefrompng(dirname(__FILE__) . '/libgd00086.png'); +var_dump($im); +?> +--EXPECTF-- + +Warning: imagecreatefrompng(): gd-png: fatal libpng error: Read Error: truncated data in %s on line %d + +Warning: imagecreatefrompng(): gd-png error: setjmp returns error condition in %s on line %d + +Warning: imagecreatefrompng(): '%s' is not a valid PNG file in %s on line %d +bool(false) diff --git a/ext/gd/tests/libgd00086.png b/ext/gd/tests/libgd00086.png Binary files differnew file mode 100644 index 0000000..0e7c8dd --- /dev/null +++ b/ext/gd/tests/libgd00086.png diff --git a/ext/gd/tests/libgd00086_extern.phpt b/ext/gd/tests/libgd00086_extern.phpt new file mode 100644 index 0000000..0c8d180 --- /dev/null +++ b/ext/gd/tests/libgd00086_extern.phpt @@ -0,0 +1,19 @@ +--TEST-- +libgd #86 (Possible infinite loop in imagecreatefrompng) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (GD_BUNDLED) die("skip requires external GD library\n"); +?> +--FILE-- +<?php + +$im = imagecreatefrompng(dirname(__FILE__) . '/libgd00086.png'); +var_dump($im); +?> +--EXPECTF-- +gd-png: fatal libpng error: Read Error: truncated data +gd-png error: setjmp returns error condition 1 + +Warning: imagecreatefrompng(): '%slibgd00086.png' is not a valid PNG file in %s on line %d +bool(false) diff --git a/ext/gd/tests/libgd00094.phpt b/ext/gd/tests/libgd00094.phpt new file mode 100644 index 0000000..d1d68ea --- /dev/null +++ b/ext/gd/tests/libgd00094.phpt @@ -0,0 +1,19 @@ +--TEST-- +libgd #94 (imagecreatefromxbm can crash if gdImageCreate fails) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php +$im = imagecreatefromxbm(dirname(__FILE__) . '/libgd00094.xbm'); +var_dump($im); +?> +--EXPECTF-- +Warning: imagecreatefromxbm(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully + in %slibgd00094.php on line %d + +Warning: imagecreatefromxbm(): '%slibgd00094.xbm' is not a valid XBM file in %slibgd00094.php on line %d +bool(false) + diff --git a/ext/gd/tests/libgd00094.xbm b/ext/gd/tests/libgd00094.xbm new file mode 100644 index 0000000..4d0f5bd --- /dev/null +++ b/ext/gd/tests/libgd00094.xbm @@ -0,0 +1,3 @@ +#define width 255 +#define height 1073741824 +static unsigned char bla = { diff --git a/ext/gd/tests/libgd00100.phpt b/ext/gd/tests/libgd00100.phpt new file mode 100644 index 0000000..abf4ee3 --- /dev/null +++ b/ext/gd/tests/libgd00100.phpt @@ -0,0 +1,119 @@ +--TEST-- +libgd #100 (spurious horizontal line drawn by gdImageFilledPolygon) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php +$im = imagecreatetruecolor(256, 256); + +$white = imagecolorallocatealpha($im, 255, 255, 255, 10); +$black = imagecolorallocatealpha($im, 0, 0, 0, 10); +$red = imagecolorallocatealpha($im, 255, 0, 0, 10); +$green = imagecolorallocatealpha($im, 0, 255, 0, 10); +$blue = imagecolorallocatealpha($im, 0, 0, 255, 10); +$yellow = imagecolorallocatealpha($im, 255, 255, 0, 10); +$cyan = imagecolorallocatealpha($im, 0, 255, 255, 10); +$magenta = imagecolorallocatealpha($im, 255, 0, 255, 10); +$purple = imagecolorallocatealpha($im, 100, 0, 100, 10); + +imagefilledrectangle($im, 0, 0, 255, 255, $white); + +// M (bridge) +$top = 240; +$bot = 255; +$d = 30; +$x = 100; +$points = array( + $x, $top, + $x+2*$d, $top, + $x+2*$d, $bot, + $x+$d, ($top+$bot)/2, + $x, $bot +); +imagefilledpolygon($im, $points, 5, $yellow); + +// left-facing M not on baseline +$top = 40; +$bot = 70; +$left = 120; +$right = 180; +$points = array( + $left, $top, + $right, $top, + $right, $bot, + $left, $bot, + ($left+$right)/2, ($top+$bot)/2 +); +imagefilledpolygon($im, $points, 5, $purple); + +// left-facing M on baseline +$top = 240; +$bot = 270; +$left = 20; +$right = 80; +$points = array( + $left, $top, + $right, $top, + $right, $bot, + $left, $bot, + ($left+$right)/2, ($top+$bot)/2 +); +imagefilledpolygon($im, $points, 5, $magenta); + +// left-facing M on ceiling +$top = -15; +$bot = 15; +$left = 20; +$right = 80; +$points = array( + $left, $top, + $right, $top, + $right, $bot, + $left, $bot, + ($left+$right)/2, ($top+$bot)/2 +); +imagefilledpolygon($im, $points, 5, $blue); + +$d = 30; +$x = 150; +$y = 150; +$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d); +imagefilledpolygon($im, $diamond, 4, $green); + +$x = 180; +$y = 225; +$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d); +imagefilledpolygon($im, $diamond, 4, $red); + +$x = 225; +$y = 255; +$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d); +imagefilledpolygon($im, $diamond, 4, $cyan); + +// M (bridge) not touching bottom boundary +$top = 100; +$bot = 150; +$x = 30; +$points = array( + $x, $top, + $x+2*$d, $top, + $x+2*$d, $bot, + $x+$d, ($top+$bot)/2, + $x, $bot +); +imagefilledpolygon($im, $points, 5, $black); + +ob_start(); +imagepng($im); +$png = ob_get_contents(); +ob_end_clean(); + +echo md5($png); + +imagedestroy($im); +?> +--EXPECTF-- +2e6cf558bb4dadf60c8b608d5f8cda4e diff --git a/ext/gd/tests/libgd00101.gd b/ext/gd/tests/libgd00101.gd new file mode 100644 index 0000000..5516ce0 --- /dev/null +++ b/ext/gd/tests/libgd00101.gd @@ -0,0 +1 @@ +ÿýÿý
\ No newline at end of file diff --git a/ext/gd/tests/libgd00101.phpt b/ext/gd/tests/libgd00101.phpt new file mode 100644 index 0000000..1c6623d --- /dev/null +++ b/ext/gd/tests/libgd00101.phpt @@ -0,0 +1,18 @@ +--TEST-- +libgd #101 (imagecreatefromgd can crash if gdImageCreate fails) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php +$im = imagecreatefromgd(dirname(__FILE__) . '/libgd00101.gd'); +var_dump($im); +?> +--EXPECTF-- +Warning: imagecreatefromgd(): gd warning: product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully + in %slibgd00101.php on line %d + +Warning: imagecreatefromgd(): '%slibgd00101.gd' is not a valid GD file in %slibgd00101.php on line %d +bool(false) diff --git a/ext/gd/tests/libgd00106.phpt b/ext/gd/tests/libgd00106.phpt new file mode 100644 index 0000000..65e4692 --- /dev/null +++ b/ext/gd/tests/libgd00106.phpt @@ -0,0 +1,22 @@ +--TEST-- +libgd #106 (imagerectangle 1x1 draws 1x3) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$im = imagecreatetruecolor(10,10); +imagerectangle($im, 1,1, 1,1, 0xFFFFFF); +$c1 = imagecolorat($im, 1,1); +$c2 = imagecolorat($im, 1,2); +$c3 = imagecolorat($im, 2,1); +$c4 = imagecolorat($im, 2,2); +if ($c1 == 0xFFFFFF && $c2 == 0 && $c3 == 0 && $c4 == 0) { + echo "Ok"; +} else { + echo "failed"; +} +?> +--EXPECT-- +Ok diff --git a/ext/gd/tests/libgd00186.phpt b/ext/gd/tests/libgd00186.phpt new file mode 100644 index 0000000..cb1686b --- /dev/null +++ b/ext/gd/tests/libgd00186.phpt @@ -0,0 +1,36 @@ +--TEST-- +libgd #186 (Tiling true colour with palette image does not work) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$im = imagecreatetruecolor(10,10); +$tile = imagecreate(10,10); +$red = imagecolorallocate($tile,0xff,0,0); +$green = imagecolorallocate($tile,0,0xff,0); +$blue = imagecolorallocate($tile,0,0,0xff); +$other = imagecolorallocate($tile,0,0,0x2); +imagefilledrectangle($tile,0,0,2,10,$red); +imagefilledrectangle($tile,3,0,4,10,$green); +imagefilledrectangle($tile,5,0,7,10,$blue); +imagefilledrectangle($tile,8,0,9,10,$other); +imagecolortransparent($tile,$blue); +imagesettile($im,$tile); +for ($i=0; $i<10; $i++) { + imagesetpixel($im,$i,$i,IMG_COLOR_TILED); +} +$index = imagecolorat($im,9,9); +$arr = imagecolorsforindex($im, $index); +if ($arr['blue'] == 2) { + $r = "Ok"; +} else { + $r = "Failed"; +} +imagedestroy($tile); +imagedestroy($im); +echo $r; +?> +--EXPECT-- +Ok diff --git a/ext/gd/tests/libgd00191.phpt b/ext/gd/tests/libgd00191.phpt new file mode 100644 index 0000000..6e3ffd5 --- /dev/null +++ b/ext/gd/tests/libgd00191.phpt @@ -0,0 +1,23 @@ +--TEST-- +libgd FS#191 (A circle becomes square) +--SKIPIF-- +<?php + if (!extension_loaded('gd')) die("skip gd extension not available\n"); + if (!GD_BUNDLED) die("skip requires bundled GD library\n"); +?> +--FILE-- +<?php +$im = imagecreatetruecolor(100, 100); +imagefilledrectangle($im, 0, 0, 100, 100, imagecolorallocate($im, 255, 255, 255)); +imagesetthickness($im, 20); +imagefilledellipse($im, 30, 50, 20, 20, imagecolorallocate($im, 0, 0, 0)); +$index = imagecolorat($im, 12, 28); +$arr = imagecolorsforindex($im, $index); +if ($arr['red'] == 255 && $arr['green'] == 255 && $arr['blue'] == 255) { + echo "Ok"; +} else { + echo "failed"; +} +?> +--EXPECT-- +Ok diff --git a/ext/gd/tests/lines.phpt b/ext/gd/tests/lines.phpt new file mode 100644 index 0000000..2c99969 --- /dev/null +++ b/ext/gd/tests/lines.phpt @@ -0,0 +1,114 @@ +--TEST-- +imageline no AA +--SKIPIF-- +<?php + if (!function_exists('imageline')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); + +// Wrong argument count +imageline($im, 0,0, 5,5); + + +// Horizontal line +imageline($im, 0,5, 5,5, 0x00ff00); + +$p1 = imagecolorat($im, 0,5)==0x00ff00; +$p2 = imagecolorat($im, 5,5)==0x00ff00; +$p3 = true; +for ($x=1; $x<5; $x++) { + $p3 = $p3 && (imagecolorat($im, $x,5)==0x00ff00); +} +if ($p1 && $p2 && $p3) { + echo "Horizontal: ok\n"; +} + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); + +imageline($im, 0,0, 0,5, 0x00ff00); +$p1 = imagecolorat($im, 0,0)==0x00ff00; +$p2 = imagecolorat($im, 0,5)==0x00ff00; +$p3 = true; +for ($y=1; $y<5; $y++) { + $p3 = $p3 && (imagecolorat($im, 0,$y)==0x00ff00); +} + +if ($p1 && $p2 && $p3) { + echo "Vertical: ok\n"; +} + + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); +imageline($im, 0,0, 5,5, 0x00ff00); + + +// Diagonal +$p1 = imagecolorat($im, 0,0)==0x00ff00; +$p2 = imagecolorat($im, 5,5)==0x00ff00; +$x=1; +$p3 = true; + +for ($y=1; $y<5; $y++) { + $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00); + $x++; +} + +if ($p1 && $p2 && $p3) { + echo "Diagonal: ok\n"; +} + +// Outside +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); +imageline($im, 12, 12, 23,23, 0x00ff00); +$p3 = true; +for ($x=0; $x<6; $x++) { + for ($y=0; $y<6; $y++) { + $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00); + } +} +if ($p3) { + echo "Outside 1: ok\n"; +} + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); +imageline($im, -12, -12, -23,-23, 0x00ff00); +$p3 = true; +for ($x=0; $x<6; $x++) { + for ($y=0; $y<6; $y++) { + $p3 = $p3 && (imagecolorat($im, $x,$y)!=0x00ff00); + } +} +if ($p3) { + echo "Outside 2: ok\n"; +} + +$im = imagecreatetruecolor(6,6); +imagefill($im, 0,0, 0xffffff); +imageline($im, -1, -1, 4,4, 0x00ff00); +$p3 = true; +for ($x=0; $x<5; $x++) { + for ($y=0; $y<5; $y++) { + $p3 = $p3 && (imagecolorat($im, $x,$y)==0x00ff00); + } +} +if ($p3) { + echo "Outside 2: ok\n"; +} + + +?> +--EXPECTF-- + +Warning: imageline() expects exactly 6 parameters, 5 given in %s on line %d +Horizontal: ok +Vertical: ok +Diagonal: ok +Outside 1: ok +Outside 2: ok diff --git a/ext/gd/tests/php.gif b/ext/gd/tests/php.gif Binary files differnew file mode 100644 index 0000000..f352c73 --- /dev/null +++ b/ext/gd/tests/php.gif diff --git a/ext/gd/tests/png2gd.phpt b/ext/gd/tests/png2gd.phpt new file mode 100644 index 0000000..65ca505 --- /dev/null +++ b/ext/gd/tests/png2gd.phpt @@ -0,0 +1,42 @@ +--TEST-- +png <--> gd1/gd2 conversion test +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + + if (!function_exists("imagecreatefrompng") || !function_exists("imagepng")) { + die("skip png support unavailable"); + } +?> +--FILE-- +<?php + $cwd = dirname(__FILE__); + + echo "PNG to GD1 conversion: "; + echo imagegd(imagecreatefrompng($cwd . "/conv_test.png"), $cwd . "/test.gd1") ? 'ok' : 'failed'; + echo "\n"; + + echo "PNG to GD2 conversion: "; + echo imagegd2(imagecreatefrompng($cwd . "/conv_test.png"), $cwd . "/test.gd2") ? 'ok' : 'failed'; + echo "\n"; + + echo "GD1 to PNG conversion: "; + echo imagepng(imagecreatefromgd($cwd . "/test.gd1"), $cwd . "/test_gd1.png") ? 'ok' : 'failed'; + echo "\n"; + + echo "GD2 to PNG conversion: "; + echo imagepng(imagecreatefromgd2($cwd . "/test.gd2"), $cwd . "/test_gd2.png") ? 'ok' : 'failed'; + echo "\n"; + + @unlink($cwd . "/test.gd1"); + @unlink($cwd . "/test.gd2"); + @unlink($cwd . "/test_gd1.png"); + @unlink($cwd . "/test_gd2.png"); +?> +--EXPECT-- +PNG to GD1 conversion: ok +PNG to GD2 conversion: ok +GD1 to PNG conversion: ok +GD2 to PNG conversion: ok diff --git a/ext/gd/tests/png2wbmp_error1.phpt b/ext/gd/tests/png2wbmp_error1.phpt new file mode 100644 index 0000000..1e9d717 --- /dev/null +++ b/ext/gd/tests/png2wbmp_error1.phpt @@ -0,0 +1,42 @@ +--TEST-- +Test png2wbmp() function : wrong threshold value param +--CREDITS-- +Levi Fukumori <levi [at] fukumori [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('png2wbmp')) { + die('skip png2wbmp function is not available'); +} +?> +--FILE-- +<?php +// Create a blank image and add some text +$im = imagecreatetruecolor(120, 20); +$text_color = imagecolorallocate($im, 255, 255, 255); +imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); + +$file = dirname(__FILE__) .'/simpletext.png'; +$file2 = dirname(__FILE__) .'/simpletext.wbmp'; + +// Save the image as 'simpletext.png' +imagepng($im, $file); + +// Free up memory +imagedestroy($im); + +png2wbmp($file, $file2, 20, 120, 9); +png2wbmp($file, $file2, 20, 120, -1); +?> +--EXPECTF-- +Warning: png2wbmp(): Invalid threshold value '9' in %s on line %d + +Warning: png2wbmp(): Invalid threshold value '-1' in %s on line %d +--CLEAN-- +<?php +unlink(dirname(__FILE__) .'/simpletext.png'); +unlink(dirname(__FILE__) .'/simpletext.wbmp'); +?> diff --git a/ext/gd/tests/png2wbmp_error2.phpt b/ext/gd/tests/png2wbmp_error2.phpt new file mode 100644 index 0000000..ba8e43e --- /dev/null +++ b/ext/gd/tests/png2wbmp_error2.phpt @@ -0,0 +1,31 @@ +--TEST-- +Test png2wbmp() function : wrong origin filename param +--CREDITS-- +Levi Fukumori <levi [at] fukumori [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('png2wbmp')) { + die('skip png2wbmp function is not available'); +} +?> +--FILE-- +<?php +$file = dirname(__FILE__) .'/simpletext.wbmp'; +png2wbmp('', $file, 20, 120, 8); +png2wbmp(null, $file, 20, 120, 8); +png2wbmp(false, $file, 20, 120, 8); +?> +--EXPECTF-- +Warning: png2wbmp(): Unable to open '' for reading in %s on line %d + +Warning: png2wbmp(): Unable to open '' for reading in %s on line %d + +Warning: png2wbmp(): Unable to open '' for reading in %s on line %d +--CLEAN-- +<?php +unlink(dirname(__FILE__) .'/simpletext.wbmp'); +?> diff --git a/ext/gd/tests/png2wbmp_error3.phpt b/ext/gd/tests/png2wbmp_error3.phpt new file mode 100644 index 0000000..1e33f59 --- /dev/null +++ b/ext/gd/tests/png2wbmp_error3.phpt @@ -0,0 +1,43 @@ +--TEST-- +Test png2wbmp() function : wrong destination filename param +--CREDITS-- +Levi Fukumori <levi [at] fukumori [dot] com [dot] br> +#testfest PHPSP on 2009-06-20 +--SKIPIF-- +<?php +if(!extension_loaded('gd')) { + die('skip gd extension is not loaded'); +} +if(!function_exists('png2wbmp')) { + die('skip png2wbmp function is not available'); +} +?> +--FILE-- +<?php +// Create a blank image and add some text +$im = imagecreatetruecolor(120, 20); +$text_color = imagecolorallocate($im, 255, 255, 255); +imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); + +$file = dirname(__FILE__) .'/simpletext.png'; + +// Save the image as 'simpletext.png' +imagepng($im, $file); + +// Free up memory +imagedestroy($im); + +png2wbmp($file, '', 20, 120, 8); +png2wbmp($file, null, 20, 120, 8); +png2wbmp($file, false, 20, 120, 8); +?> +--EXPECTF-- +Warning: png2wbmp(): Unable to open '' for writing in %s on line %d + +Warning: png2wbmp(): Unable to open '' for writing in %s on line %d + +Warning: png2wbmp(): Unable to open '' for writing in %s on line %d +--CLEAN-- +<?php +unlink(dirname(__FILE__) .'/simpletext.png'); +?> diff --git a/ext/gd/tests/pngcomp.phpt b/ext/gd/tests/pngcomp.phpt new file mode 100644 index 0000000..3fd7b57 --- /dev/null +++ b/ext/gd/tests/pngcomp.phpt @@ -0,0 +1,32 @@ +--TEST-- +png compression test +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + + if (!function_exists("imagecreatefrompng") || !function_exists("imagepng")) { + die("skip png support unavailable"); + } +?> +--FILE-- +<?php + $cwd = dirname(__FILE__); + + echo "PNG compression test: "; + + $im = imagecreatetruecolor(20,20); + imagefilledrectangle($im, 5,5, 10,10, 0xffffff); + imagepng($im, $cwd . '/test_pngcomp.png', 9); + + $im2 = imagecreatefrompng($cwd . '/test_pngcomp.png'); + $col = imagecolorat($im2, 8,8); + if ($col == 0xffffff) { + echo "ok\n"; + } + + @unlink($cwd . "/test_pngcomp.png"); +?> +--EXPECT-- +PNG compression test: ok diff --git a/ext/gd/tests/src.gd2 b/ext/gd/tests/src.gd2 Binary files differnew file mode 100644 index 0000000..1c64b46 --- /dev/null +++ b/ext/gd/tests/src.gd2 diff --git a/ext/gd/tests/src.png b/ext/gd/tests/src.png Binary files differnew file mode 100644 index 0000000..d38c742 --- /dev/null +++ b/ext/gd/tests/src.png diff --git a/ext/gd/tests/src.wbmp b/ext/gd/tests/src.wbmp Binary files differnew file mode 100644 index 0000000..d38c742 --- /dev/null +++ b/ext/gd/tests/src.wbmp diff --git a/ext/gd/tests/test.png b/ext/gd/tests/test.png Binary files differnew file mode 100644 index 0000000..27c5d46 --- /dev/null +++ b/ext/gd/tests/test.png diff --git a/ext/gd/tests/test8859.ttf b/ext/gd/tests/test8859.ttf Binary files differnew file mode 100644 index 0000000..dff237c --- /dev/null +++ b/ext/gd/tests/test8859.ttf diff --git a/ext/gd/tests/types.phpt b/ext/gd/tests/types.phpt new file mode 100644 index 0000000..0b79e78 --- /dev/null +++ b/ext/gd/tests/types.phpt @@ -0,0 +1,33 @@ +--TEST-- +imagetypes +--SKIPIF-- +<?php + if (!function_exists('imagetypes')) die("skip gd extension not available\n"); +?> +--FILE-- +<?php +$flags = imagetypes(); + +if ($flags&0x1 && !function_exists("imagegif")) { + echo "gif failed\n"; +} + +if ($flags&0x2 && !function_exists("imagejpeg")) { + echo "jpeg failed\n"; +} + +if ($flags&0x4 && !function_exists("imagepng")) { + echo "png failed\n"; +} + +if ($flags&0x8 && !function_exists("imagewbmp")) { + echo "wbmp failed\n"; +} + +if ($flags&16 && !function_exists("imagecreatefromxpm")) { + echo "xom failed\n"; +} +echo "ok\n"; +?> +--EXPECTF-- +ok diff --git a/ext/gd/tests/xbm2png.phpt b/ext/gd/tests/xbm2png.phpt new file mode 100644 index 0000000..6edebc0 --- /dev/null +++ b/ext/gd/tests/xbm2png.phpt @@ -0,0 +1,26 @@ +--TEST-- +xbm --> png conversion test +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + if (!function_exists("imagepng")) { + die("skip png support unavailable"); + } + if (!function_exists("imagecreatefromxbm")) { + die("skip xbm read support unavailable"); + } +?> +--FILE-- +<?php + $cwd = dirname(__FILE__); + + echo "XBM to PNG conversion: "; + echo imagepng(imagecreatefromxbm($cwd . "/conv_test.xbm"), $cwd . "/test_xbm.png") ? 'ok' : 'failed'; + echo "\n"; + + @unlink($cwd . "/test_xbm.png"); +?> +--EXPECT-- +XBM to PNG conversion: ok diff --git a/ext/gd/tests/xpm2gd.phpt b/ext/gd/tests/xpm2gd.phpt new file mode 100644 index 0000000..e70a13f --- /dev/null +++ b/ext/gd/tests/xpm2gd.phpt @@ -0,0 +1,30 @@ +--TEST-- +xpm --> gd1/gd2 conversion test +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + + if (!function_exists("imagecreatefromxpm")) { + die("skip xpm read support unavailable"); + } +?> +--FILE-- +<?php + $cwd = dirname(__FILE__); + + echo "XPM to GD1 conversion: "; + echo imagegd(imagecreatefromxpm($cwd . "/conv_test.xpm"), $cwd . "/test.gd1") ? 'ok' : 'failed'; + echo "\n"; + + echo "XPM to GD2 conversion: "; + echo imagegd2(imagecreatefromxpm($cwd . "/conv_test.xpm"), $cwd . "/test.gd2") ? 'ok' : 'failed'; + echo "\n"; + + @unlink($cwd . "/test.gd1"); + @unlink($cwd . "/test.gd2"); +?> +--EXPECT-- +XPM to GD1 conversion: ok +XPM to GD2 conversion: ok diff --git a/ext/gd/tests/xpm2jpg.phpt b/ext/gd/tests/xpm2jpg.phpt new file mode 100644 index 0000000..d412b07 --- /dev/null +++ b/ext/gd/tests/xpm2jpg.phpt @@ -0,0 +1,27 @@ +--TEST-- +xpm --> jpeg conversion test +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + + if (!function_exists("imagejpeg")) { + die("skip jpeg support unavailable"); + } + if (!function_exists("imagecreatefromxpm")) { + die("skip xpm read support unavailable"); + } +?> +--FILE-- +<?php + $cwd = dirname(__FILE__); + + echo "XPM to JPEG conversion: "; + echo imagejpeg(imagecreatefromxpm($cwd . "/conv_test.xpm"), $cwd . "/test_xpm.jpeg") ? 'ok' : 'failed'; + echo "\n"; + + @unlink($cwd . "/test_xpm.jpeg"); +?> +--EXPECT-- +XPM to JPEG conversion: ok diff --git a/ext/gd/tests/xpm2png.phpt b/ext/gd/tests/xpm2png.phpt new file mode 100644 index 0000000..a5eadff --- /dev/null +++ b/ext/gd/tests/xpm2png.phpt @@ -0,0 +1,27 @@ +--TEST-- +xpm --> png conversion test +--SKIPIF-- +<?php + if (!extension_loaded('gd')) { + die("skip gd extension not available."); + } + + if (!function_exists("imagepng")) { + die("skip png support unavailable"); + } + if (!function_exists("imagecreatefromxpm")) { + die("skip xpm read support unavailable"); + } +?> +--FILE-- +<?php + $cwd = dirname(__FILE__); + + echo "XPM to PNG conversion: "; + echo imagepng(imagecreatefromxpm($cwd . "/conv_test.xpm"), $cwd . "/test_xpm.png") ? 'ok' : 'failed'; + echo "\n"; + + @unlink($cwd . "/test_xpm.png"); +?> +--EXPECT-- +XPM to PNG conversion: ok |