note 41445 added to function.imagecolorstotal

From: Date: Sat, 10 Apr 2004 06:19:51 +0000
Subject: note 41445 added to function.imagecolorstotal
Groups: php.notes 
Request: Send a blank email to php-notes+get-67945@lists.php.net to get a copy of this message
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); ?> Check the manual for the function signature. Cheers. ---- Manual Page -- http://www.php.net/manual/en/function.imagecolorstotal.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41445 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41445&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41445&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67945) next »