php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65749 getimagesize not returning channels for png and bmp
Submitted: 2013-09-24 06:49 UTC Modified: 2013-09-25 23:00 UTC
From: nettum at gmail dot com Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2013-09-24 06:49 UTC] nettum at gmail dot com
Description:
------------
getimagesize does not contain 'channel' in the returning array when you run 
getimagesize on a PNG or BMP image.

The documentation (http://php.net/manual/en/function.getimagesize.php) specifies 
that it will always return an array with 7 elements. This does not seem to be the 
case. Se script output below.

Test script:
---------------
<?php
$file_jpg = "test.jpg";
$file_png = "tux.png";

$info_jpg = getimagesize($file_jpg);
$info_png = getimagesize($file_png);

echo "\nJPG:";
print_r($info_jpg);

echo "\nPNG:";
print_r($info_png);
?>


Expected result:
----------------
JPG:Array
(
    [0] => 463
    [1] => 399
    [2] => 2
    [3] => width="463" height="399"
    [bits] => 8
    [channels] => 3
    [mime] => image/jpeg
)

PNG:Array
(
    [0] => 400
    [1] => 479
    [2] => 3
    [3] => width="400" height="479"
    [bits] => 8
    [channels] => 4
    [mime] => image/png
)


Actual result:
--------------
JPG:Array
(
    [0] => 463
    [1] => 399
    [2] => 2
    [3] => width="463" height="399"
    [bits] => 8
    [channels] => 3
    [mime] => image/jpeg
)

PNG:Array
(
    [0] => 400
    [1] => 479
    [2] => 3
    [3] => width="400" height="479"
    [bits] => 8
    [mime] => image/png
)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-09-25 22:55 UTC] aharvey@php.net
-Status: Open +Status: Assigned -Type: Bug +Type: Documentation Problem -Package: GetImageSize related +Package: Documentation problem -Assigned To: +Assigned To: aharvey
 [2013-09-25 22:55 UTC] aharvey@php.net
Looks like a documentation problem, rather than a code one — the getimagesize() 
code is pretty clear that channels and bits are optional, depending on the image 
type.
 [2013-09-25 23:00 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=331495
Log: Note that channels and bits aren't mandatory return fields for getimagesize().

Fixes doc bug #65749 (getimagesize not returning channels for png and bmp).
 [2013-09-25 23:00 UTC] aharvey@php.net
-Status: Assigned +Status: Closed
 [2013-09-25 23:00 UTC] aharvey@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Sep 25 01:03:38 2021 UTC