note 41370 added to function.imagecreatefromjpeg

From: Date: Wed, 07 Apr 2004 22:02:15 +0000
Subject: note 41370 added to function.imagecreatefromjpeg
Groups: php.notes 
Request: Send a blank email to php-notes+get-67782@lists.php.net to get a copy of this message
small script that calculates square (in %) of eche color on the PNG image. <? $t1=time(); $im1=ImageCreatefrompng('1.png'); //name of the png file echo "<img src=1.png>"; $widthIm=ImageSX($im1); $heightIm=ImageSY($im1); $total=$widthIm*$heightIm; $cvcol=imagecolorstotal($im1); for ($i=0; $i<$widthIm; $i++){ for ($j=0; $j<$heightIm; $j++){ $tochka=imagecolorat($im1,$i,$j); $num[$tochka]=$num[$tochka]+1; } } echo "<br><br>$widthIm x $heightIm ($total pixels)."; echo " Number of colors in pallette - $cvcol<br><br> "; echo "<table width=400 border =1>"; for ($k=0; $k<$cvcol; $k++) { $proc=round($num[$k]/$total*100, 2); $Palitra =ImageColorsForIndex($im1,$k); $Palitra[red]= dechex($Palitra[red]); $Palitra[green]= dechex($Palitra[green]); $Palitra[blue]= dechex($Palitra[blue]); echo "<tr><td>$k</td><td width=100>$Palitra[red]-$Palitra[green]-$Palitra[blue]</td>"; echo "<td width=100>$proc %</td>"; echo "<td width=100 bgcolor=$Palitra[red],$Palitra"; echo "[green],$Palitra[blue]>&nbsp;</td></tr>"; } echo "</table>"; imagedestroy($im1); $t2=-$t1+time(); echo "<br>Time past: $t2 sec"; ?> ---- Manual Page -- http://www.php.net/manual/en/function.imagecreatefromjpeg.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+41370 Delete -- http://master.php.net/manage/user-notes.php?action=delete+41370&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+41370&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#67782) next »