用php查找PNG图像的通道数
如何使用php查找PNG图像的通道数 根据getimagesize()的文档,这个函数似乎总是返回通道数 据我所知,情况并非如此。 以下是一个例子: channel_test.php:用php查找PNG图像的通道数,php,png,gd,imagick,Php,Png,Gd,Imagick,如何使用php查找PNG图像的通道数 根据getimagesize()的文档,这个函数似乎总是返回通道数 据我所知,情况并非如此。 以下是一个例子: channel_test.php: <?php $path1 = "test.jpg"; $path2 = "homer.gif"; $path3 = "bmp_24.bmp"; $path4 = "tux.png"; $info1 = getimagesize($path1); $info2 = getimagesize($path2);
<?php
$path1 = "test.jpg";
$path2 = "homer.gif";
$path3 = "bmp_24.bmp";
$path4 = "tux.png";
$info1 = getimagesize($path1);
$info2 = getimagesize($path2);
$info3 = getimagesize($path3);
$info4 = getimagesize($path4);
echo "\nJPG:";
print_r($info1);
echo "\nGIF:";
print_r($info2);
echo "\nBMP:";
print_r($info3);
echo "\nPNG:";
print_r($info4);
?>
JPG:Array
(
[0] => 463
[1] => 399
[2] => 2
[3] => width="463" height="399"
[bits] => 8
[channels] => 3
[mime] => image/jpeg
)
GIF:Array
(
[0] => 320
[1] => 320
[2] => 1
[3] => width="320" height="320"
[bits] => 8
[channels] => 3
[mime] => image/gif
)
BMP:Array
(
[0] => 200
[1] => 200
[2] => 6
[3] => width="200" height="200"
[bits] => 24
[mime] => image/x-ms-bmp
)
PNG:Array
(
[0] => 400
[1] => 479
[2] => 3
[3] => width="400" height="479"
[bits] => 8
[mime] => image/png
)
如您所见,BMP和PNG图像不会返回通道数。
这是错误还是预期的行为?
如果这是意料之中的,我认为php文档有点误导
还有其他方法可以获得频道的数量吗
我正在运行PHP5.4.9(linux),gd和imagick都已安装。这看起来像是一个遗漏。代码根本不存在。code:我报告这是一个错误:至少文档已从“返回一个包含7个元素的数组”更改为“返回一个包含最多7个元素的数组。并非所有图像类型都将包含通道和位元素”。。。