|
użytkowników online: 92
|
OPINIE UŻYTKOWNIKÓW
|
Z mojej strony serwisowi należy się bardzo mocna pochwała. Nawet późna pora zgłoszenia problemu (23.00) nie przeszkodziła Darkowi w jego rozwiązaniu. Do tego poziom odpisywania na maile jest bardzo wysoki... wszystko wykłada jak cierpliwy nauczyciel. Śmiało mogę przyznać, że zamieszczone na stronach porady są rzeczowo opisane - a nie jak to bywa w innych serwisach mamy sam kod i nic poza tym! Jeszcze raz wielkie dzięki!
Damian Jarosz
Adminer.pl
|
|
PODRĘCZNIK PHP 5.x, 4.x, 3.x - częściowo spolszczony / źródło: www.php.net
[Spis]
[A]
[B]
[C]
[D]
[E]
[F]
[G]
[H]
[I]
[J]
[K]
[L]
[M]
[N]
[O]
[P]
[Q]
[R]
[S]
[T]
[U]
[V]
[X]
[W]
[Z]
imagecolorstotal (PHP 3, PHP 4, PHP 5) imagecolorstotal -- Find out the number of colors in an image's palette
User Contributed NotesFelix Rusu <webmaster at betania dot ro>
10-Apr-2004 11:19
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.
love at tobe dot spamed
26-Jan-2004 10:33
to mgi : imagecolorstotal() function use a resource image. So doesn't take care about the image file format used. Even if you use a non-palette file format such as jpeg, it should work because it uses the palette built in the resource image... I'm wondering if I'm true.
black-eye at web dot de
01-Nov-2003 04:34
I created a function to count the colors in a .gif file automatically. Works perfect on Win2k Servers
<?PHP
function bildinfo($bild)
{
$fp = fopen($bild, "rb"); $f = fread($fp, filesize($bild));
$c = bin2hex($f); $c = ereg_replace("5c30", "0000", $c); $b = $c;
$pos = strpos($c, "fe0102"); if ($pos > 0)
{
$c = substr($c, 26);
$c = substr($c, 0, strpos($c, "fe0102")); }
else
{
$c = substr($c, 26);
$c = substr($c, 0, strpos($c, "21f904")); }
echo "<table border='0'>";
$i = 0;
$y = 0;
$str = "";
$pix = chunk_split($c, 6, ";"); $pix = explode(";",$pix);
sort($pix);
foreach($pix as $col)
{
if ($col && !ereg($col.";", $str) && strlen($col) == 6) {
$str .= $col.";";
$i++;
|