diff options
Diffstat (limited to 'ext/gd')
24 files changed, 410 insertions, 4 deletions
diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 9375aeee1e..119bc8fec4 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -992,7 +992,7 @@ ZEND_GET_MODULE(gd) /* {{{ PHP_INI_BEGIN */ PHP_INI_BEGIN() - PHP_INI_ENTRY("gd.jpeg_ignore_warning", "0", PHP_INI_ALL, NULL) + PHP_INI_ENTRY("gd.jpeg_ignore_warning", "1", PHP_INI_ALL, NULL) PHP_INI_END() /* }}} */ @@ -2828,14 +2828,14 @@ PHP_FUNCTION(imagecolorat) if (im->tpixels && gdImageBoundsSafe(im, x, y)) { RETURN_LONG(gdImageTrueColorPixel(im, x, y)); } else { - php_error_docref(NULL, E_NOTICE, "%pd,%pd is out of bounds", x, y); + php_error_docref(NULL, E_NOTICE, "" ZEND_LONG_FMT "," ZEND_LONG_FMT " is out of bounds", x, y); RETURN_FALSE; } } else { if (im->pixels && gdImageBoundsSafe(im, x, y)) { RETURN_LONG(im->pixels[y][x]); } else { - php_error_docref(NULL, E_NOTICE, "%pd,%pd is out of bounds", x, y); + php_error_docref(NULL, E_NOTICE, "" ZEND_LONG_FMT "," ZEND_LONG_FMT " is out of bounds", x, y); RETURN_FALSE; } } @@ -4869,7 +4869,7 @@ PHP_FUNCTION(imageaffinematrixget) } default: - php_error_docref(NULL, E_WARNING, "Invalid type for element %li", type); + php_error_docref(NULL, E_WARNING, "Invalid type for element " ZEND_LONG_FMT, type); RETURN_FALSE; } diff --git a/ext/gd/tests/001-mb.phpt b/ext/gd/tests/001-mb.phpt new file mode 100644 index 0000000000..743df7d2c7 --- /dev/null +++ b/ext/gd/tests/001-mb.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 100644 index 0000000000..8ea647090f --- /dev/null +++ b/ext/gd/tests/Tuffy私はガラスを食べられます.ttf diff --git a/ext/gd/tests/bug22544-mb.phpt b/ext/gd/tests/bug22544-mb.phpt new file mode 100644 index 0000000000..94d16ab96b --- /dev/null +++ b/ext/gd/tests/bug22544-mb.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/bug36697-mb.phpt b/ext/gd/tests/bug36697-mb.phpt new file mode 100644 index 0000000000..b0b69a394f --- /dev/null +++ b/ext/gd/tests/bug36697-mb.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-mb.phpt b/ext/gd/tests/bug37346-mb.phpt new file mode 100644 index 0000000000..90efc6391b --- /dev/null +++ b/ext/gd/tests/bug37346-mb.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-mb.php on line %d diff --git a/ext/gd/tests/bug37346私はガラスを食べられます.gif b/ext/gd/tests/bug37346私はガラスを食べられます.gif new file mode 100644 index 0000000000..b8453f015e --- /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/bug38212-mb.phpt b/ext/gd/tests/bug38212-mb.phpt new file mode 100644 index 0000000000..905865f28f --- /dev/null +++ b/ext/gd/tests/bug38212-mb.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/bug39286-mb.phpt b/ext/gd/tests/bug39286-mb.phpt new file mode 100644 index 0000000000..d926fac38e --- /dev/null +++ b/ext/gd/tests/bug39286-mb.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/bug48732-mb.phpt b/ext/gd/tests/bug48732-mb.phpt new file mode 100644 index 0000000000..7713e51190 --- /dev/null +++ b/ext/gd/tests/bug48732-mb.phpt @@ -0,0 +1,27 @@ +--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'); + if (substr(PHP_OS, 0, 3) != 'WIN') { + die('skip.. only for Windows'); + } +?> +--XFAIL-- +seems freetype issue, to investigate +--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-mb.phpt b/ext/gd/tests/bug48801-mb.phpt new file mode 100644 index 0000000000..cbd7624c67 --- /dev/null +++ b/ext/gd/tests/bug48801-mb.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) +(15%d, 15) +(15%d, -48) +(-1, -48) diff --git a/ext/gd/tests/bug66339-mb.phpt b/ext/gd/tests/bug66339-mb.phpt new file mode 100644 index 0000000000..76e3af7c8f --- /dev/null +++ b/ext/gd/tests/bug66339-mb.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug #66339 (PHP segfaults in imagexbm) +--SKIPIF-- +<?php +if (!extension_loaded('gd')) die('skip gd extension not available'); +?> +--FILE-- +<?php +$im = imagecreate(8, 8); +imagecolorallocate($im, 0, 0, 0); // background +$white = imagecolorallocate($im, 255, 255, 255); +imagefilledrectangle($im, 2, 2, 6, 6, $white); +imagexbm($im, NULL); +echo "------------\n"; +imagexbm($im, './bug66339私はガラスを食べられます.xbm'); +echo file_get_contents('./bug66339私はガラスを食べられます.xbm'); +?> +--CLEAN-- +<?php +unlink('./bug66339私はガラスを食べられます.xbm'); +?> +--EXPECTF-- +#define image_width 8 +#define image_height 8 +static unsigned char image_bits[] = { + 0xFF, 0xFF, 0x83, 0x83, 0x83, 0x83, 0x83, 0xFF}; +------------ +#define bug66339%swidth 8 +#define bug66339%sheight 8 +static unsigned char bug66339%sbits[] = { + 0xFF, 0xFF, 0x83, 0x83, 0x83, 0x83, 0x83, 0xFF}; diff --git a/ext/gd/tests/bug71912-mb.phpt b/ext/gd/tests/bug71912-mb.phpt new file mode 100644 index 0000000000..5714e107ce --- /dev/null +++ b/ext/gd/tests/bug71912-mb.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #71912 (libgd: signedness vulnerability) +--SKIPIF-- +<?php + if(!extension_loaded('gd')){ die('skip gd extension not available'); } + if(!function_exists('imagecreatefromgd2')) die('skip imagecreatefromgd2() not available'); +?> +--FILE-- +<?php +imagecreatefromgd2(__DIR__ . DIRECTORY_SEPARATOR . "invalid_neg_size私はガラスを食べられます.gd2"); +?> +OK +--EXPECTF-- + +Warning: imagecreatefromgd2(): '%s%einvalid_neg_size私はガラスを食べられます.gd2' is not a valid GD2 file in %s%ebug71912-mb.php on line %d +OK diff --git a/ext/gd/tests/conv_test私はガラスを食べられます.jpeg b/ext/gd/tests/conv_test私はガラスを食べられます.jpeg Binary files differnew file mode 100644 index 0000000000..7283d1a475 --- /dev/null +++ b/ext/gd/tests/conv_test私はガラスを食べられます.jpeg diff --git a/ext/gd/tests/createfromwbmp-mb.phpt b/ext/gd/tests/createfromwbmp-mb.phpt new file mode 100644 index 0000000000..50e8a18780 --- /dev/null +++ b/ext/gd/tests/createfromwbmp-mb.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/imagewbmp-mb.phpt b/ext/gd/tests/imagewbmp-mb.phpt new file mode 100644 index 0000000000..bb6cfdc655 --- /dev/null +++ b/ext/gd/tests/imagewbmp-mb.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/invalid_neg_size私はガラスを食べられます.gd2 b/ext/gd/tests/invalid_neg_size私はガラスを食べられます.gd2 Binary files differnew file mode 100644 index 0000000000..3075f15a81 --- /dev/null +++ b/ext/gd/tests/invalid_neg_size私はガラスを食べられます.gd2 diff --git a/ext/gd/tests/jpeg2wbmp_error2-mb.phpt b/ext/gd/tests/jpeg2wbmp_error2-mb.phpt new file mode 100644 index 0000000000..a1c91b1397 --- /dev/null +++ b/ext/gd/tests/jpeg2wbmp_error2-mb.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/jpg2gd-mb.phpt b/ext/gd/tests/jpg2gd-mb.phpt new file mode 100644 index 0000000000..8dee6b3bd5 --- /dev/null +++ b/ext/gd/tests/jpg2gd-mb.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/libgd00094-mb.phpt b/ext/gd/tests/libgd00094-mb.phpt new file mode 100644 index 0000000000..a5e55baa96 --- /dev/null +++ b/ext/gd/tests/libgd00094-mb.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-mb.php on line %d + +Warning: imagecreatefromxbm(): '%slibgd00094私はガラスを食べられます.xbm' is not a valid XBM file in %slibgd00094-mb.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 0000000000..4d0f5bdd87 --- /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/png2wbmp_error1-mb.phpt b/ext/gd/tests/png2wbmp_error1-mb.phpt new file mode 100644 index 0000000000..a19cf5e017 --- /dev/null +++ b/ext/gd/tests/png2wbmp_error1-mb.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/simpletext私はガラスを食べられます.jpg b/ext/gd/tests/simpletext私はガラスを食べられます.jpg Binary files differnew file mode 100644 index 0000000000..c527d7982f --- /dev/null +++ b/ext/gd/tests/simpletext私はガラスを食べられます.jpg diff --git a/ext/gd/tests/src私はガラスを食べられます.wbmp b/ext/gd/tests/src私はガラスを食べられます.wbmp Binary files differnew file mode 100644 index 0000000000..d38c74268a --- /dev/null +++ b/ext/gd/tests/src私はガラスを食べられます.wbmp |
