Thanks Richard,
Renamed and attached.
-----Original Message-----
From: Richard Quadling [mailto:[email protected]]
Sent: 08 July 2011 17:13
To: DIXON P.
Cc: [email protected]
Subject: Re: [PHP-DEV] [PATCH] getimagesize - return named keys for width,
height, type and attributes
On 8 July 2011 17:10, DIXON P. <[email protected]> wrote:
> Hi,
>
> I've attached a patch ...
Rename as .txt to get through the mailing list s/w.
--
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea
diff --git a/ext/standard/image.c b/ext/standard/image.c
index 5383667..004dc8d 100644
--- a/ext/standard/image.c
+++ b/ext/standard/image.c
@@ -1364,8 +1364,10 @@ static void php_getimagesize_from_stream(php_stream
*stream, zval **info, INTERN
add_index_long(return_value, 0, result->width);
add_index_long(return_value, 1, result->height);
add_index_long(return_value, 2, itype);
+
spprintf(&temp, 0, "width=\"%d\" height=\"%d\"", result->width,
result->height);
add_index_string(return_value, 3, temp, 0);
+ add_assoc_string(return_value, "attributes", temp, 1);
if (result->bits != 0) {
add_assoc_long(return_value, "bits", result->bits);
@@ -1373,7 +1375,12 @@ static void php_getimagesize_from_stream(php_stream
*stream, zval **info, INTERN
if (result->channels != 0) {
add_assoc_long(return_value, "channels",
result->channels);
}
+
+ add_assoc_long(return_value, "height", result->height);
add_assoc_string(return_value, "mime",
(char*)php_image_type_to_mime_type(itype), 1);
+ add_assoc_long(return_value, "type", itype);
+ add_assoc_long(return_value, "width", result->width);
+
efree(result);
} else {
RETURN_FALSE;
diff --git a/ext/standard/tests/image/bug13213.phpt
b/ext/standard/tests/image/bug13213.phpt
index c97b701..530cb99 100644
--- a/ext/standard/tests/image/bug13213.phpt
+++ b/ext/standard/tests/image/bug13213.phpt
@@ -5,7 +5,7 @@ Bug #13213 (GetImageSize and wrong JPEG Comments)
var_dump(GetImageSize(dirname(__FILE__).'/bug13213.jpg'));
?>
--EXPECT--
-array(7) {
+array(11) {
[0]=>
int(1)
[1]=>
@@ -14,10 +14,18 @@ array(7) {
int(2)
[3]=>
string(20) "width="1" height="1""
+ ["attributes"]=>
+ string(20) "width="1" height="1""
["bits"]=>
int(8)
["channels"]=>
int(3)
+ ["height"]=>
+ int(1)
["mime"]=>
string(10) "image/jpeg"
+ ["type"]=>
+ int(2)
+ ["width"]=>
+ int(1)
}
diff --git a/ext/standard/tests/image/getimagesize.phpt
b/ext/standard/tests/image/getimagesize.phpt
index ab79c9c..b11a5f2 100644
--- a/ext/standard/tests/image/getimagesize.phpt
+++ b/ext/standard/tests/image/getimagesize.phpt
@@ -25,7 +25,7 @@ GetImageSize()
--EXPECT--
array(11) {
["test1pix.bmp"]=>
- array(6) {
+ array(10) {
[0]=>
int(1)
[1]=>
@@ -34,13 +34,21 @@ array(11) {
int(6)
[3]=>
string(20) "width="1" height="1""
+ ["attributes"]=>
+ string(20) "width="1" height="1""
["bits"]=>
int(24)
+ ["height"]=>
+ int(1)
["mime"]=>
string(14) "image/x-ms-bmp"
+ ["type"]=>
+ int(6)
+ ["width"]=>
+ int(1)
}
["test1pix.jp2"]=>
- array(7) {
+ array(11) {
[0]=>
int(1)
[1]=>
@@ -49,15 +57,23 @@ array(11) {
int(10)
[3]=>
string(20) "width="1" height="1""
+ ["attributes"]=>
+ string(20) "width="1" height="1""
["bits"]=>
int(8)
["channels"]=>
int(3)
+ ["height"]=>
+ int(1)
["mime"]=>
string(9) "image/jp2"
+ ["type"]=>
+ int(10)
+ ["width"]=>
+ int(1)
}
["test1pix.jpc"]=>
- array(7) {
+ array(11) {
[0]=>
int(1)
[1]=>
@@ -66,15 +82,23 @@ array(11) {
int(9)
[3]=>
string(20) "width="1" height="1""
+ ["attributes"]=>
+ string(20) "width="1" height="1""
["bits"]=>
int(8)
["channels"]=>
int(3)
+ ["height"]=>
+ int(1)
["mime"]=>
string(24) "application/octet-stream"
+ ["type"]=>
+ int(9)
+ ["width"]=>
+ int(1)
}
["test1pix.jpg"]=>
- array(7) {
+ array(11) {
[0]=>
int(1)
[1]=>
@@ -83,15 +107,23 @@ array(11) {
int(2)
[3]=>
string(20) "width="1" height="1""
+ ["attributes"]=>
+ string(20) "width="1" height="1""
["bits"]=>
int(8)
["channels"]=>
int(3)
+ ["height"]=>
+ int(1)
["mime"]=>
string(10) "image/jpeg"
+ ["type"]=>
+ int(2)
+ ["width"]=>
+ int(1)
}
["test2pix.gif"]=>
- array(7) {
+ array(11) {
[0]=>
int(2)
[1]=>
@@ -100,15 +132,23 @@ array(11) {
int(1)
[3]=>
string(20) "width="2" height="1""
+ ["attributes"]=>
+ string(20) "width="2" height="1""
["bits"]=>
int(1)
["channels"]=>
int(3)
+ ["height"]=>
+ int(1)
["mime"]=>
string(9) "image/gif"
+ ["type"]=>
+ int(1)
+ ["width"]=>
+ int(2)
}
["test4pix.gif"]=>
- array(7) {
+ array(11) {
[0]=>
int(4)
[1]=>
@@ -117,15 +157,23 @@ array(11) {
int(1)
[3]=>
string(20) "width="4" height="1""
+ ["attributes"]=>
+ string(20) "width="4" height="1""
["bits"]=>
int(2)
["channels"]=>
int(3)
+ ["height"]=>
+ int(1)
["mime"]=>
string(9) "image/gif"
+ ["type"]=>
+ int(1)
+ ["width"]=>
+ int(4)
}
["test4pix.iff"]=>
- array(6) {
+ array(10) {
[0]=>
int(4)
[1]=>
@@ -134,13 +182,21 @@ array(11) {
int(14)
[3]=>
string(20) "width="4" height="1""
+ ["attributes"]=>
+ string(20) "width="4" height="1""
["bits"]=>
int(4)
+ ["height"]=>
+ int(1)
["mime"]=>
string(9) "image/iff"
+ ["type"]=>
+ int(14)
+ ["width"]=>
+ int(4)
}
["test4pix.png"]=>
- array(6) {
+ array(10) {
[0]=>
int(4)
[1]=>
@@ -149,13 +205,21 @@ array(11) {
int(3)
[3]=>
string(20) "width="4" height="1""
+ ["attributes"]=>
+ string(20) "width="4" height="1""
["bits"]=>
int(4)
+ ["height"]=>
+ int(1)
["mime"]=>
string(9) "image/png"
+ ["type"]=>
+ int(3)
+ ["width"]=>
+ int(4)
}
["test4pix.psd"]=>
- array(5) {
+ array(9) {
[0]=>
int(4)
[1]=>
@@ -164,11 +228,19 @@ array(11) {
int(5)
[3]=>
string(20) "width="4" height="1""
+ ["attributes"]=>
+ string(20) "width="4" height="1""
+ ["height"]=>
+ int(1)
["mime"]=>
string(9) "image/psd"
+ ["type"]=>
+ int(5)
+ ["width"]=>
+ int(4)
}
["test4pix.swf"]=>
- array(5) {
+ array(9) {
[0]=>
int(550)
[1]=>
@@ -177,11 +249,19 @@ array(11) {
int(4)
[3]=>
string(24) "width="550" height="400""
+ ["attributes"]=>
+ string(24) "width="550" height="400""
+ ["height"]=>
+ int(400)
["mime"]=>
string(29) "application/x-shockwave-flash"
+ ["type"]=>
+ int(4)
+ ["width"]=>
+ int(550)
}
["test4pix.tif"]=>
- array(5) {
+ array(9) {
[0]=>
int(4)
[1]=>
@@ -190,7 +270,15 @@ array(11) {
int(7)
[3]=>
string(20) "width="4" height="1""
+ ["attributes"]=>
+ string(20) "width="4" height="1""
+ ["height"]=>
+ int(1)
["mime"]=>
string(10) "image/tiff"
+ ["type"]=>
+ int(7)
+ ["width"]=>
+ int(4)
}
}
diff --git a/ext/standard/tests/image/getimagesize_246x247.phpt
b/ext/standard/tests/image/getimagesize_246x247.phpt
index e5a0aea..f6f353e 100644
--- a/ext/standard/tests/image/getimagesize_246x247.phpt
+++ b/ext/standard/tests/image/getimagesize_246x247.phpt
@@ -25,7 +25,7 @@ GetImageSize() with 246x247 pixels
--EXPECT--
array(1) {
["246x247.png"]=>
- array(6) {
+ array(10) {
[0]=>
int(246)
[1]=>
@@ -34,9 +34,17 @@ array(1) {
int(3)
[3]=>
string(24) "width="246" height="247""
+ ["attributes"]=>
+ string(24) "width="246" height="247""
["bits"]=>
int(4)
+ ["height"]=>
+ int(247)
["mime"]=>
string(9) "image/png"
+ ["type"]=>
+ int(3)
+ ["width"]=>
+ int(246)
}
}
diff --git a/ext/standard/tests/image/getimagesize_384x385.phpt
b/ext/standard/tests/image/getimagesize_384x385.phpt
index 0051df7..37ad4fa 100644
--- a/ext/standard/tests/image/getimagesize_384x385.phpt
+++ b/ext/standard/tests/image/getimagesize_384x385.phpt
@@ -25,7 +25,7 @@ GetImageSize() with 384x385 pixels
--EXPECT--
array(1) {
["384x385.png"]=>
- array(6) {
+ array(10) {
[0]=>
int(384)
[1]=>
@@ -34,9 +34,17 @@ array(1) {
int(3)
[3]=>
string(24) "width="384" height="385""
+ ["attributes"]=>
+ string(24) "width="384" height="385""
["bits"]=>
int(1)
+ ["height"]=>
+ int(385)
["mime"]=>
string(9) "image/png"
+ ["type"]=>
+ int(3)
+ ["width"]=>
+ int(384)
}
}
diff --git a/ext/standard/tests/image/getimagesize_basic.phpt
b/ext/standard/tests/image/getimagesize_basic.phpt
index 4d47225..57bd7c4 100644
--- a/ext/standard/tests/image/getimagesize_basic.phpt
+++ b/ext/standard/tests/image/getimagesize_basic.phpt
@@ -50,7 +50,7 @@ foreach($imagetype_filenames as $key => $filename) {
*** Testing getimagesize() : basic functionality ***
-- GIF image file (200x100.gif) --
-array(7) {
+array(11) {
[0]=>
int(200)
[1]=>
@@ -59,18 +59,26 @@ array(7) {
int(1)
[3]=>
string(24) "width="200" height="100""
+ ["attributes"]=>
+ string(24) "width="200" height="100""
["bits"]=>
int(8)
["channels"]=>
int(3)
+ ["height"]=>
+ int(100)
["mime"]=>
string(9) "image/gif"
+ ["type"]=>
+ int(1)
+ ["width"]=>
+ int(200)
}
array(0) {
}
-- JPEG image file (200x100.jpg) --
-array(7) {
+array(11) {
[0]=>
int(200)
[1]=>
@@ -79,12 +87,20 @@ array(7) {
int(2)
[3]=>
string(24) "width="200" height="100""
+ ["attributes"]=>
+ string(24) "width="200" height="100""
["bits"]=>
int(8)
["channels"]=>
int(3)
+ ["height"]=>
+ int(100)
["mime"]=>
string(10) "image/jpeg"
+ ["type"]=>
+ int(2)
+ ["width"]=>
+ int(200)
}
array(1) {
["APP0"]=>
@@ -92,7 +108,7 @@ array(1) {
}
-- PNG image file (200x100.png) --
-array(6) {
+array(10) {
[0]=>
int(200)
[1]=>
@@ -101,16 +117,24 @@ array(6) {
int(3)
[3]=>
string(24) "width="200" height="100""
+ ["attributes"]=>
+ string(24) "width="200" height="100""
["bits"]=>
int(8)
+ ["height"]=>
+ int(100)
["mime"]=>
string(9) "image/png"
+ ["type"]=>
+ int(3)
+ ["width"]=>
+ int(200)
}
array(0) {
}
-- SWF image file (200x100.swf) --
-array(5) {
+array(9) {
[0]=>
int(200)
[1]=>
@@ -119,14 +143,22 @@ array(5) {
int(4)
[3]=>
string(24) "width="200" height="100""
+ ["attributes"]=>
+ string(24) "width="200" height="100""
+ ["height"]=>
+ int(100)
["mime"]=>
string(29) "application/x-shockwave-flash"
+ ["type"]=>
+ int(4)
+ ["width"]=>
+ int(200)
}
array(0) {
}
-- BMP image file (200x100.bmp) --
-array(6) {
+array(10) {
[0]=>
int(200)
[1]=>
@@ -135,16 +167,24 @@ array(6) {
int(6)
[3]=>
string(24) "width="200" height="100""
+ ["attributes"]=>
+ string(24) "width="200" height="100""
["bits"]=>
int(24)
+ ["height"]=>
+ int(100)
["mime"]=>
string(14) "image/x-ms-bmp"
+ ["type"]=>
+ int(6)
+ ["width"]=>
+ int(200)
}
array(0) {
}
-- TIFF intel byte order image file (200x100.tif) --
-array(5) {
+array(9) {
[0]=>
int(200)
[1]=>
@@ -153,14 +193,22 @@ array(5) {
int(7)
[3]=>
string(24) "width="200" height="100""
+ ["attributes"]=>
+ string(24) "width="200" height="100""
+ ["height"]=>
+ int(100)
["mime"]=>
string(10) "image/tiff"
+ ["type"]=>
+ int(7)
+ ["width"]=>
+ int(200)
}
array(0) {
}
-- JPC image file (test1pix.jpc) --
-array(7) {
+array(11) {
[0]=>
int(1)
[1]=>
@@ -169,18 +217,26 @@ array(7) {
int(9)
[3]=>
string(20) "width="1" height="1""
+ ["attributes"]=>
+ string(20) "width="1" height="1""
["bits"]=>
int(8)
["channels"]=>
int(3)
+ ["height"]=>
+ int(1)
["mime"]=>
string(24) "application/octet-stream"
+ ["type"]=>
+ int(9)
+ ["width"]=>
+ int(1)
}
array(0) {
}
-- JP2 image file (test1pix.jp2) --
-array(7) {
+array(11) {
[0]=>
int(1)
[1]=>
@@ -189,18 +245,26 @@ array(7) {
int(10)
[3]=>
string(20) "width="1" height="1""
+ ["attributes"]=>
+ string(20) "width="1" height="1""
["bits"]=>
int(8)
["channels"]=>
int(3)
+ ["height"]=>
+ int(1)
["mime"]=>
string(9) "image/jp2"
+ ["type"]=>
+ int(10)
+ ["width"]=>
+ int(1)
}
array(0) {
}
-- IFF image file (test4pix.iff) --
-array(6) {
+array(10) {
[0]=>
int(4)
[1]=>
@@ -209,10 +273,18 @@ array(6) {
int(14)
[3]=>
string(20) "width="4" height="1""
+ ["attributes"]=>
+ string(20) "width="4" height="1""
["bits"]=>
int(4)
+ ["height"]=>
+ int(1)
["mime"]=>
string(9) "image/iff"
+ ["type"]=>
+ int(14)
+ ["width"]=>
+ int(4)
}
array(0) {
}
diff --git a/ext/standard/tests/image/getimagesize_swc.phpt
b/ext/standard/tests/image/getimagesize_swc.phpt
index f8c7449..1f60863 100644
--- a/ext/standard/tests/image/getimagesize_swc.phpt
+++ b/ext/standard/tests/image/getimagesize_swc.phpt
@@ -11,7 +11,7 @@ GetImageSize() for compressed swf files
var_dump(getimagesize(dirname(__FILE__) . "/test13pix.swf"));
?>
--EXPECT--
-array(5) {
+array(9) {
[0]=>
int(550)
[1]=>
@@ -20,6 +20,14 @@ array(5) {
int(13)
[3]=>
string(24) "width="550" height="400""
+ ["attributes"]=>
+ string(24) "width="550" height="400""
+ ["height"]=>
+ int(400)
["mime"]=>
string(29) "application/x-shockwave-flash"
+ ["type"]=>
+ int(13)
+ ["width"]=>
+ int(550)
}
diff --git a/ext/standard/tests/image/getimagesize_tif_mm.phpt
b/ext/standard/tests/image/getimagesize_tif_mm.phpt
index 8bc88fd..0d2e3ac 100644
--- a/ext/standard/tests/image/getimagesize_tif_mm.phpt
+++ b/ext/standard/tests/image/getimagesize_tif_mm.phpt
@@ -22,7 +22,7 @@ var_dump($arr);
===DONE===
--EXPECT--
*** Testing getimagesize() : tiff_mm format ***
-array(5) {
+array(9) {
[0]=>
int(2)
[1]=>
@@ -31,8 +31,16 @@ array(5) {
int(8)
[3]=>
string(20) "width="2" height="2""
+ ["attributes"]=>
+ string(20) "width="2" height="2""
+ ["height"]=>
+ int(2)
["mime"]=>
string(10) "image/tiff"
+ ["type"]=>
+ int(8)
+ ["width"]=>
+ int(2)
}
array(0) {
}
diff --git a/ext/standard/tests/image/getimagesize_variation4.phpt
b/ext/standard/tests/image/getimagesize_variation4.phpt
index 8fa690c..650e8cf 100644
--- a/ext/standard/tests/image/getimagesize_variation4.phpt
+++ b/ext/standard/tests/image/getimagesize_variation4.phpt
@@ -21,7 +21,7 @@ var_dump( $info );
===DONE===
--EXPECTF--
*** Testing getimagesize() : variation ***
-array(5) {
+array(9) {
[0]=>
int(550)
[1]=>
@@ -30,8 +30,16 @@ array(5) {
int(13)
[3]=>
string(24) "width="550" height="400""
+ ["attributes"]=>
+ string(24) "width="550" height="400""
+ ["height"]=>
+ int(400)
["mime"]=>
string(29) "application/x-shockwave-flash"
+ ["type"]=>
+ int(13)
+ ["width"]=>
+ int(550)
}
array(0) {
}
diff --git a/ext/standard/tests/image/getimagesize_variation_005.phpt
b/ext/standard/tests/image/getimagesize_variation_005.phpt
index 6f0ad8f..7546bb4 100644
--- a/ext/standard/tests/image/getimagesize_variation_005.phpt
+++ b/ext/standard/tests/image/getimagesize_variation_005.phpt
@@ -21,7 +21,7 @@ var_dump( $info );
===DONE===
--EXPECTF--
*** Testing getimagesize() : basic functionality ***
-array(5) {
+array(9) {
[0]=>
int(550)
[1]=>
@@ -30,8 +30,16 @@ array(5) {
int(13)
[3]=>
string(24) "width="550" height="400""
+ ["attributes"]=>
+ string(24) "width="550" height="400""
+ ["height"]=>
+ int(400)
["mime"]=>
string(29) "application/x-shockwave-flash"
+ ["type"]=>
+ int(13)
+ ["width"]=>
+ int(550)
}
array(0) {
}
diff --git a/ext/standard/tests/image/getimagesize_wbmp.phpt
b/ext/standard/tests/image/getimagesize_wbmp.phpt
index 503b5f1..244b927 100644
--- a/ext/standard/tests/image/getimagesize_wbmp.phpt
+++ b/ext/standard/tests/image/getimagesize_wbmp.phpt
@@ -22,7 +22,7 @@ var_dump($arr);
===DONE===
--EXPECT--
*** Testing getimagesize() : wbmp format ***
-array(5) {
+array(9) {
[0]=>
int(75)
[1]=>
@@ -31,8 +31,16 @@ array(5) {
int(15)
[3]=>
string(22) "width="75" height="50""
+ ["attributes"]=>
+ string(22) "width="75" height="50""
+ ["height"]=>
+ int(50)
["mime"]=>
string(18) "image/vnd.wap.wbmp"
+ ["type"]=>
+ int(15)
+ ["width"]=>
+ int(75)
}
array(0) {
}
diff --git a/ext/standard/tests/image/getimagesize_xbm.phpt
b/ext/standard/tests/image/getimagesize_xbm.phpt
index 53406a8..6d10fbd 100644
--- a/ext/standard/tests/image/getimagesize_xbm.phpt
+++ b/ext/standard/tests/image/getimagesize_xbm.phpt
@@ -22,7 +22,7 @@ var_dump($arr);
===DONE===
--EXPECT--
*** Testing getimagesize() : xbm format ***
-array(5) {
+array(9) {
[0]=>
int(75)
[1]=>
@@ -31,8 +31,16 @@ array(5) {
int(16)
[3]=>
string(22) "width="75" height="50""
+ ["attributes"]=>
+ string(22) "width="75" height="50""
+ ["height"]=>
+ int(50)
["mime"]=>
string(9) "image/xbm"
+ ["type"]=>
+ int(16)
+ ["width"]=>
+ int(75)
}
array(0) {
}
diff --git a/ext/standard/tests/image/getimagesizefromstring1.phpt
b/ext/standard/tests/image/getimagesizefromstring1.phpt
index df75be5..52f2db6 100644
--- a/ext/standard/tests/image/getimagesizefromstring1.phpt
+++ b/ext/standard/tests/image/getimagesizefromstring1.phpt
@@ -14,7 +14,7 @@ var_dump($i1);
var_dump($i2);
?>
--EXPECT--
-array(7) {
+array(11) {
[0]=>
int(120)
[1]=>
@@ -23,14 +23,22 @@ array(7) {
int(1)
[3]=>
string(23) "width="120" height="67""
+ ["attributes"]=>
+ string(23) "width="120" height="67""
["bits"]=>
int(7)
["channels"]=>
int(3)
+ ["height"]=>
+ int(67)
["mime"]=>
string(9) "image/gif"
+ ["type"]=>
+ int(1)
+ ["width"]=>
+ int(120)
}
-array(7) {
+array(11) {
[0]=>
int(120)
[1]=>
@@ -39,11 +47,19 @@ array(7) {
int(1)
[3]=>
string(23) "width="120" height="67""
+ ["attributes"]=>
+ string(23) "width="120" height="67""
["bits"]=>
int(7)
["channels"]=>
int(3)
+ ["height"]=>
+ int(67)
["mime"]=>
string(9) "image/gif"
+ ["type"]=>
+ int(1)
+ ["width"]=>
+ int(120)
}
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php