summaryrefslogtreecommitdiff
path: root/ext/gd
diff options
context:
space:
mode:
Diffstat (limited to 'ext/gd')
-rw-r--r--ext/gd/gd.c6
-rw-r--r--ext/gd/gd_ctx.c4
-rw-r--r--ext/gd/libgd/gdft.c3
-rw-r--r--ext/gd/libgd/xbm.c4
-rw-r--r--ext/gd/php_gd.h4
-rw-r--r--ext/gd/tests/gd_info_basic.phpt29
-rw-r--r--ext/gd/tests/image_type_to_mime_type_basic.phpt64
-rw-r--r--ext/gd/tests/imagecopyresampled_basic.phpt71
-rw-r--r--ext/gd/tests/imagedashedline_basic.phpt78
-rw-r--r--ext/gd/tests/imagefilledpolygon_basic.phpt102
-rw-r--r--ext/gd/tests/imagepolygon_basic.phpt80
11 files changed, 435 insertions, 10 deletions
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index b12a7ecf9..541ed86e9 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd.c,v 1.312.2.20.2.32 2007/09/11 21:03:48 pajoye Exp $ */
+/* $Id: gd.c,v 1.312.2.20.2.34 2008/04/04 17:39:52 felipe Exp $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
@@ -2813,7 +2813,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
}
}
- if ((argc == 2) || (argc > 2 && Z_STRLEN_PP(file))) {
+ if (argc >= 2 && Z_STRLEN_PP(file)) {
PHP_GD_CHECK_OPEN_BASEDIR(fn, "Invalid filename");
fp = VCWD_FOPEN(fn, "wb");
diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c
index 773462f99..cd721b3f9 100644
--- a/ext/gd/gd_ctx.c
+++ b/ext/gd/gd_ctx.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gd_ctx.c,v 1.22.2.5.2.3 2007/01/01 09:36:01 sebastian Exp $ */
+/* $Id: gd_ctx.c,v 1.22.2.5.2.4 2007/12/31 07:20:06 sebastian Exp $ */
#include "php_gd.h"
diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c
index 49a540c42..e543f2fe2 100644
--- a/ext/gd/libgd/gdft.c
+++ b/ext/gd/libgd/gdft.c
@@ -947,7 +947,8 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
/* EAM DEBUG */
#if (defined(FREETYPE_MAJOR) && ((FREETYPE_MAJOR == 2 && ((FREETYPE_MINOR == 1 && FREETYPE_PATCH >= 3) || FREETYPE_MINOR > 1) || FREETYPE_MAJOR > 2)))
- if (font->face->charmap->encoding == FT_ENCODING_MS_SYMBOL && strcmp(font->face->family_name, "Symbol") == 0) {
+ if (font->face->family_name && font->face->charmap->encoding &&
+ font->face->charmap->encoding == FT_ENCODING_MS_SYMBOL && strcmp(font->face->family_name, "Symbol") == 0) {
/* I do not know the significance of the constant 0xf000.
* It was determined by inspection of the character codes
* stored in Microsoft font symbol.
diff --git a/ext/gd/libgd/xbm.c b/ext/gd/libgd/xbm.c
index 30ed3cf4a..6e7f473a9 100644
--- a/ext/gd/libgd/xbm.c
+++ b/ext/gd/libgd/xbm.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: xbm.c,v 1.7.2.2.2.2 2007/08/09 12:08:29 mattias Exp $ */
+/* $Id: xbm.c,v 1.7.2.2.2.3 2007/12/31 07:20:06 sebastian Exp $ */
#include <stdio.h>
#include <math.h>
diff --git a/ext/gd/php_gd.h b/ext/gd/php_gd.h
index 05ccab1d3..6c981f3ce 100644
--- a/ext/gd/php_gd.h
+++ b/ext/gd/php_gd.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
+ | Copyright (c) 1997-2008 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_gd.h,v 1.59.2.3.2.5 2007/04/17 15:31:45 pajoye Exp $ */
+/* $Id: php_gd.h,v 1.59.2.3.2.6 2007/12/31 07:20:06 sebastian Exp $ */
#ifndef PHP_GD_H
#define PHP_GD_H
diff --git a/ext/gd/tests/gd_info_basic.phpt b/ext/gd/tests/gd_info_basic.phpt
new file mode 100644
index 000000000..61a2304e8
--- /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/image_type_to_mime_type_basic.phpt b/ext/gd/tests/image_type_to_mime_type_basic.phpt
new file mode 100644
index 000000000..7384c4632
--- /dev/null
+++ b/ext/gd/tests/image_type_to_mime_type_basic.phpt
@@ -0,0 +1,64 @@
+--TEST--
+image_type_to_mime_type()
+--SKIPIF--
+<?php
+ if (!function_exists('image_type_to_mime_type')) die('skip image_type_to_mime_type() not available');
+ require_once('skipif_imagetype.inc');
+?>
+--FILE--
+<?php
+
+/* Prototype : string image_type_to_mime_type ( int $imagetype )
+ * Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype.
+ * Source code: ext/standard/image.c
+ * Alias to functions:
+ */
+
+echo "Starting image_type_to_mime_type() test\n\n";
+
+$image_types = array (
+ IMAGETYPE_GIF,
+ IMAGETYPE_JPEG,
+ IMAGETYPE_PNG,
+ IMAGETYPE_SWF,
+ IMAGETYPE_PSD,
+ IMAGETYPE_BMP,
+ IMAGETYPE_TIFF_II,
+ IMAGETYPE_TIFF_MM,
+ IMAGETYPE_JPC,
+ IMAGETYPE_JP2,
+ IMAGETYPE_JPX,
+ IMAGETYPE_JB2,
+ IMAGETYPE_IFF,
+ IMAGETYPE_WBMP,
+ IMAGETYPE_JPEG2000,
+ IMAGETYPE_XBM
+);
+
+ foreach($image_types as $image_type) {
+ var_dump(image_type_to_mime_type($image_type));
+ }
+
+echo "\nDone image_type_to_mime_type() test\n";
+?>
+--EXPECT--
+Starting image_type_to_mime_type() test
+
+string(9) "image/gif"
+string(10) "image/jpeg"
+string(9) "image/png"
+string(29) "application/x-shockwave-flash"
+string(9) "image/psd"
+string(9) "image/bmp"
+string(10) "image/tiff"
+string(10) "image/tiff"
+string(24) "application/octet-stream"
+string(9) "image/jp2"
+string(24) "application/octet-stream"
+string(24) "application/octet-stream"
+string(9) "image/iff"
+string(18) "image/vnd.wap.wbmp"
+string(24) "application/octet-stream"
+string(9) "image/xbm"
+
+Done image_type_to_mime_type() test \ No newline at end of file
diff --git a/ext/gd/tests/imagecopyresampled_basic.phpt b/ext/gd/tests/imagecopyresampled_basic.phpt
new file mode 100644
index 000000000..12ac15511
--- /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');
+ require_once('skipif_imagetype.inc');
+?>
+--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/imagedashedline_basic.phpt b/ext/gd/tests/imagedashedline_basic.phpt
new file mode 100644
index 000000000..1d6797520
--- /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');
+ require_once('skipif_imagetype.inc');
+?>
+--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/imagefilledpolygon_basic.phpt b/ext/gd/tests/imagefilledpolygon_basic.phpt
new file mode 100644
index 000000000..6871a28b7
--- /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');
+ require_once('skipif_imagetype.inc');
+?>
+--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/imagepolygon_basic.phpt b/ext/gd/tests/imagepolygon_basic.phpt
new file mode 100644
index 000000000..5c79cdf5b
--- /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