Actually that is not true.
When you use for example imagecreatefromjpeg() you create a truecolor image resource (as with the other truecolor image types). If you try to get the number of colors using imagecolorstotal() you get 0 (thats what happened to me at least). Instead you must convert the trucolor resource to pallete resource. You have to do that like this:<?
$simg=createfromjpeg("somejpeg.jpg");
imagetruecolortopalette($simg, false, 256);
$colors=imagecolorstotal($simg);
?>
When you use for example imagecreatefromjpeg() you create a truecolor image resource (as with the other truecolor image types). If you try to get the number of colors using imagecolorstotal() you get 0 (thats what happened to me at least). Instead you must convert the trucolor resource to pallete resource. You have to do that like this:<?
$simg=createfromjpeg("somejpeg.jpg");
imagetruecolortopalette($simg, false, 256);
$colors=imagecolorstotal($simg);
?>
解决方案 »
- Incorrect integer value: '男' for column 'phonenumber' at row 1
- PHP数值传递问题
- php如何按顺序排列数组?还有,如何判断一个数组的某个值已经存在
- php获取table里的数据
- php中session问题
- 问个fopen的问题....请问下面的错误如何解决...服务器为WIN系统.
- 删除数据库中记录的普遍问题,在线等.........
- 请问PHP以模块方式运行与命令行方式有什么区别.
- html转php后页面混乱,求教
- 公司要与其他网站合作,要求开发接口,供合作方调用,返回的数据是json或xml格式的
- 升星,散分--------- 1 颗小星星的诞生记
- *********走过路过的进来看看啊*************
<?Header("Content-type: image/jpeg");?>
<body>
<?
$image="swallow.jpg";
$im = imagecreatefromjpeg($image);
imagetruecolortopalette($im, false, 256);
echo $image.' has '.imagecolorstotal($im).' colors in its palette';
imagedestroy($im);
?>
</body>结果总是swallow.jpg has 256 colors in its palette;2.另外,我用imagecopy(),得到的temp.jpg全都是黑色的。
$image="swallow.jpg";
$im1 = imagecreatefromjpeg($image);
$im2=imagecreate(43,39);
imagetruecolortopalette($im1, false, 256);
imagetruecolortopalette($im2, false, 256);
imagecopy($im1,$im2,1,1,1,1,40,30);
imagejpeg($im2,"temp.jpg"); 帮帮忙啊!
$image="swallow.jpg";
$im1 = imagecreatefromjpeg($image);
$im2=imagecreate(43,39);
imagetruecolortopalette($im1, false, 256);
imagetruecolortopalette($im2, false, 256);
imagecopy($im1,$im2,1,1,1,1,40,30);
imagejpeg($im2,"temp.jpg"); 2.imagecolorat()的问题:
<body>
<?
$image="swallow.jpg";
$im = imagecreatefromjpeg($image);
$cindex = imagecolorat($im,0,0);
$rgb_color=imagecolorsforindex($im,$cindex);
echo $rgb_color['red'];
echo $rgb_color['green'];
echo $rgb_color['blue'];
?>
</body>执行到“$cindex = imagecolorat($im,0,0);”时,
总是弹出内存不能为读得提示