/    Sign up×
Community /Pin to ProfileBookmark

How to create and display multle images at one time using php Gd Library.

Hi Guys,

I am trying to get my PHP skills up to scratch switching to PHP Gd Library To Create Images From Existing One , I wanted To create Multiple images at one time how it is possible on fly . i have an application where i assign the color of an image according to color assigned to the category of the person means i have to colorize the images through PHP GD Library Filter I have an code here sharing with you that colorize the image according to the color assigned
But in this Example only one image is displayed while i wanted to create multiple images plz do help me. I am looking for Your Quick Response .
Thanks In Advance

:cursing:
—————————————–

Cheers:pinguin:
For ex: its working only one image displays

<?php //function to assign color and make backgroung white
function imagefilterhue($im,$r,$g,$b){
$rgb= $r+$g+$b;
$col = array($r/$rgb,$b/$rgb,$g/$rgb);
$height = imagesy($im);
$width = imagesx($im);
for($x=0; $x<$width; $x++){
for($y=0; $y<$height; $y++){
$rgb = imagecolorat($im, $x, $y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> 8) & 0xFF;
$b = $rgb & 0xFF;
$newR = $r*$col[0] + $g*$col[1] + $b*$col[2];
$newG = $r*
$col[2] + $g*$col[0] + $b*$col[1];
$newB = $r*$col[1] + $g*$col[2] + $b*$col[0];
imagesetpixel($im, $x, $y,imagecolorallocate($im, $newR, $newG, $new?);
}
}
}

mysql_connect(“localhost”,”root”,””);
mysql_select_db(“icondb”);
$sql=”select * from icontbl”;
$result=mysql_query($sql);
if(!mysql_num_rows($result))
{
echo mysql_error();
}
else
{ $col=array();
while($row=mysql_fetch_array($result))
{
$col[]=$row[‘color’];
$nm[]=$row[‘name’];
$icnp[]=$row[‘iconpath’];
}
$value=implode(“,”,$col);
$vl=explode(“,”,$value);

$value=implode(“,”,$nm);
$nm=explode(“,”,$value);

$value=implode(“,”,$icnp);
$icnp=explode(“,”,$value);
for($i=0;$i<count($col);$i++) {
$vl[$i];
// “</br>”;
//echo “<img src=””.$icnp[$i].”” width=”30px” height=”30px” />”;
$nm[$i];
//echo “</br>”;
$icnp[$i];
//echo “</br>”;
}
for($i=0;$i<10; $i++)
{
$st[$i]=$vl[$i];
$st[$i]=substr($st[$i],1,6);
$st[$i];
$r=hexdec(substr($st[$i],0,2));
$g=hexdec(substr($st[$i],2,2));
$b=hexdec(substr($st[$i],4,2));
$im=imagecreatefromjpeg($icnp[$i]);
header(“Content-type:image/jpeg”);
imagefilterhue($im,$r,$g,$b);
imagejpeg($im);
//imagedestroy($im);
echo “<img src=”Huzecolorimage2.php” width=”40px” height=”40px”>”; }
}

?>
</body>
</html>

Accepting The Challengs_____________?________oh Na…….

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @raviprog spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...