Jump to content

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

- - - - -

  • Please log in to reply
No replies to this topic

#1
Rajesh

Rajesh

    Newbie

  • Members
  • Pip
  • 2 posts
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, $newB));

			}

		}

	}

	

	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>

Edited by Roger, 28 December 2010 - 07:06 PM.
added code block





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users