Jump to content

[SOLVED] Image on Image help


whiteboikyle

Recommended Posts

<?php
include("config.php");
if(isset($_GET['id'])){
if(isset($_GET['img'])){
	if(ctype_digit($_GET['id'])){
		$query = $config->query("SELECT * FROM `members` WHERE `id` = '".mysql_escape_string($_GET['id'])."'");
		if(mysql_num_rows($query) == 1){
			$row = mysql_fetch_array($query);
			$result7 = $config->query("SELECT * FROM `games` WHERE ID = '".$row['game']."'");
			$game = $row2['image']; // Could be a Gif or Png
			$im = imagecreatefrompng($_GET['img']);
			//image.php?memberpic=".$_GET['id'
			if(!$im)
			{
				die("");
			}
			$font = "arial.ttf";
			$yellow = imagecolorallocate($im, 255, 255, 0);
			$black = imagecolorallocate($im, 0, 0, 0);
			$white = imagecolorallocate($im, 255, 255, 255);
			imagettftext($im, 10, 0, 165, 30, $white, $font, "Name: ".$row['username']);
			imagettftext($im, 10, 0, 165, 55, $white, $font, "Recruits: ".$row['recruits']);
			imagettftext($im, 10, 0, 165, 80, $white, $font, "Days In Clan: ".finddsl($row['joined']));
			imagettftext($im, 10, 0, 165, 105, $white, $font, "AIM: ".$row['aim']);
			imagettftext($im, 10, 0, 165, 130, $white, $font, "DSL: ".finddsl($row['timestamp']));

			imagettftext($im, 10, 0, 305, 30, $white, $font, "Main Game");
			imagecopymerge($im, $game, 165, 50, 24, 14, 24, 15, 75);
			//imagestring($im, 3, 165, 15, "TESTING", $white);
			header('Content-type: image/png');
			imagepng($im);
			imagedestroy($im);
		}
		else{
			die("The ID you submitted came back as 0 results");
		}
	}
	else{
		die("ID must be numeric!");
	}
}
else{
	die();
}
}
else{
die();
}
?>

 

error output

 

Warning: imagecopymerge(): supplied argument is not a valid Image resource in /mnt/w0903/d19/s29/b02ee83c/www/clanan.net/testy.php on line 28

 

Warning: Cannot modify header information - headers already sent by (output started at /mnt/w0903/d19/s29/b02ee83c/www/clanan.net/testy.php:28) in /mnt/w0903/d19/s29/b02ee83c/www/clanan.net/testy.php on line 30

 

Warning: Cannot modify header information - headers already sent by (output started at /mnt/w0903/d19/s29/b02ee83c/www/clanan.net/testy.php:28) in /mnt/w0903/d19/s29/b02ee83c/www/clanan.net/testy.php on line 31

‰PNG ��� IHDR�����–���óI2�� �IDATxœì½{´¥WU'ú›s®õíÇ9§*•Jª€ÞÈ3‚¢WEÁ <„„|¶ Ø´[ñ*^>¸í㎎¶Õn¤m¹ D^Q H륵%/„¤*!!ï¤êœ³÷þ¾µÖœ÷¹Ö·wzŒûÇý“=jTí:gïï[ùøÍßœk~À7_ß|}óõÍ×7_ß|}óõÍ×7_ÿÿ¾Èÿùìå9ˆ´$Mƒ™v³Ãò„–b%™™™ÂüíÅ"“9›–Ü/ˆÅL‰8÷˜3�+…ˆÀ€%�Óm–À¡KËÝ8Û!™`4Z’™ù‡U‹å$ÝD0Ë«…Á Å�¨úð‰˜9P§ÝÖÁ8Û!‘(¡SÍ&DÔmbâñF¥d�¦9ËܯL3�3+%ùÄ4§~qÂò`D¡›i4 6.ˆˆ˜XX„8°D‘¥“@ìkˆÛr11±Ä ±01�5ebPÝÓ3ƒ`‰Ìä¿Ò\Ô”€’ ™©–:ÕRò� äAsZÜGɽ•¬¥˜b!"Mƒš±tS"P†UI}I«’z-ÙJÖ’M‹ß½n/‡(q"ÝlûŒs¦KìLÍLY¢–D,ÌB$Dâ@DÖ„ÉÌ`Æ,cɦ f�ÌäËWr63�.'¦zò®[—÷ß¡%Õ!i±RL‹Z1UÓâË¢i°’´ÓbªmC™ã0€` "3µR�ó="’À!²’ÈXIéˆ%̶™ª#I�@"hâ.¡ság qºMD$ªiX–´ò‰P[8]ìff*aâÃ#fbI«}–úŸÎí;U0š,ùÂÆ',LD¾ž0ÈÈe€fªþ+3�"r`¦Ä„ökhÉDD$ªYµhJê—»÷ô{÷å~‘‡eVUK1+Öä¡J; 1K7åM @˜Ì\D©NDüójšûEÝ SS53À`ê%AXª»Ä¿ Lµ-ù;/~-€0*aN«§Ýlg°&%÷$¥€„ �|ì_¨c%*y“yI½ë„®ä¡fFª Ò’Aœ‡%K´å13ŸCN«f)°¸±LSUH¨“‚Õ©mˆ¼ZHœkV:àn:‡ª‘ ˜ê¨r*%—”\ÅT3˜cˆˆxºÝÍvT3Kq’ó°:yOî÷«\œj³ˆ…ˆCœ°D¸ðUSŠµµ"vi‰M³ÁĪ…êž©©ŽJ¢9™‘j×�˜jÉ)Ä©AE‚™šf1SæÀ‘ÃdKK6�0hNMJÌ 033b“yñ_1XÈ%¸)±–ÈÒqˆÝÖA—œÍTSω ȆÜIJ©Ö¿‰ÌÈÌ@d @KQ˜Q7!"-:n[ÉQ(óƒGÒrWKÒœM³63JÅÿKnXa>'¹>XÑb–0"¨f¨š #ÁÔ´1¨±‘‚´ ±iZœ$b–гD2¨Ìˆ¥äÁ5Gº©jvÏgfä­¥Ù 22K=131`®S%'ß¾¶U„`D€Á`2‚™

Link to comment
Share on other sites

Where is $row2 in the following being set? -

 

$game = $row2['image']

 

That line sets $game, which is used in imagecopymerge(). $game not having a value is causing the "supplied argument is not a valid Image resource", which is the reason for the first error message.

 

Notice errors are apparently disabled on your development system. You would have received a Notice error about $row2['image'] not existing if error_reporting was set to E_ALL. When learning php, developing php code, or debugging php code, always do it on a system with error_reporting set to E_ALL and display_errors set to ON to get php to help you.

Link to comment
Share on other sites

<?php
error_reporting(E_ALL); 
include("config.php");
if(isset($_GET['id'])){
if(isset($_GET['img'])){
	if(ctype_digit($_GET['id'])){
		$query = $config->query("SELECT * FROM `members` WHERE `id` = '".mysql_escape_string($_GET['id'])."'");
		if(mysql_num_rows($query) == 1){
			$row = mysql_fetch_array($query);
			$result7 = $config->query("SELECT * FROM `games` WHERE ID = '".$row['game']."'");
			$row2 = mysql_fetch_array($result7);
			$game = $row2['image']; // Could be a Gif or Png
			$im = imagecreatefrompng($_GET['img']);
			//image.php?memberpic=".$_GET['id'
			if(!$im)
			{
				die("");
			}
			$font = "arial.ttf";
			$yellow = imagecolorallocate($im, 255, 255, 0);
			$black = imagecolorallocate($im, 0, 0, 0);
			$white = imagecolorallocate($im, 255, 255, 255);
			imagettftext($im, 10, 0, 165, 30, $white, $font, "Name: ".$row['username']);
			imagettftext($im, 10, 0, 165, 55, $white, $font, "Recruits: ".$row['recruits']);
			imagettftext($im, 10, 0, 165, 80, $white, $font, "Days In Clan: ".finddsl($row['joined']));
			imagettftext($im, 10, 0, 165, 105, $white, $font, "AIM: ".$row['aim']);
			imagettftext($im, 10, 0, 165, 130, $white, $font, "DSL: ".finddsl($row['timestamp']));

			imagettftext($im, 10, 0, 305, 30, $white, $font, "Main Game");
			imagecopymerge($im, $game, 165, 50, 24, 14, 24, 15, 75);
			//imagestring($im, 3, 165, 15, "TESTING", $white);
			header('Content-type: image/png');
			imagepng($im);
			imagedestroy($im);
		}
		else{
			die("The ID you submitted came back as 0 results");
		}
	}
	else{
		die("ID must be numeric!");
	}
}
else{
	die();
}
}
else{
die();
}
?>

 

 

Warning: imagecopymerge(): supplied argument is not a valid Image resource in /mnt/w0903/d19/s29/b02ee83c/www/clanan.net/testy.php on line 30

 

Warning: Cannot modify header information - headers already sent by (output started at /mnt/w0903/d19/s29/b02ee83c/www/clanan.net/testy.php:30) in /mnt/w0903/d19/s29/b02ee83c/www/clanan.net/testy.php on line 32

‰PNG ��� IHDR�����–���óI2�� �IDATxœì½{´¥WU'ú›s®õíÇ9§*•Jª€ÞÈ3‚¢WEÁ <„„|¶ Ø´[ñ*^>¸í㎎¶Õn¤m¹ D^Q H륵%/„¤*!!ï¤êœ³÷þ¾µÖœ÷¹Ö·wzŒûÇý“=jTí:gïï[ùøÍßœk~À7_ß|}óõÍ×7_ß|}óõÍ×7_ÿÿ¾Èÿùìå9ˆ´$Mƒ™v³Ãò„–b%™™™ÂüíÅ"“9›–Ü/ˆÅL‰8÷˜3�+…ˆÀ€%�Óm–À¡KËÝ8Û!™`4Z’™ù‡U‹å$ÝD0Ë«…Á Å�¨úð‰˜9P§ÝÖÁ8Û!‘(¡SÍ&DÔmbâñF¥d�¦9ËܯL3�3+%ùÄ4§~qÂò`D¡›i4 6.ˆˆ˜XX„8°D‘¥“@ìkˆÛr11±Ä ±01�5ebPÝÓ3ƒ`‰Ìä¿Ò\Ô”€’

Link to comment
Share on other sites

What exactly is in $row2['image'];? Is it the file name of an image or is it the actual image data?

 

imagecopymerge() takes two GD image resources - http://us3.php.net/imagecopymerge The first one is $im and it is an image resource. The second value is $game. You must use take whatever is in $row2['image'] and produce a GD image resource in $game.

Link to comment
Share on other sites

Doesn't talk much does he!

 

How is one going to help he who doesn't provide details!

 

Questions:

#1 What is in the field Image (exactly) image name/path, image blob ?

#2 how do you know its image type ?

#3 do you want help ?

 

1) Its a image location like "images/cs.gif"

2) Its either a .gif or a .png

3) Yes please :)

 

and what does

src_x

and

src_y

exactly mean?

 

btw i got it to work but it only shows it as a big white space

 

testy.php?id=155&img=sig_gen.png

cs.gif

 

 

<?php
error_reporting(E_ALL); 
include("config.php");
if(isset($_GET['id'])){
if(isset($_GET['img'])){
	if(ctype_digit($_GET['id'])){
		$query = $config->query("SELECT * FROM `members` WHERE `id` = '".mysql_escape_string($_GET['id'])."'");
		if(mysql_num_rows($query) == 1){
			$row = mysql_fetch_array($query);
			$result7 = $config->query("SELECT * FROM `games` WHERE ID = '".$row['game']."'");
			$row2 = mysql_fetch_array($result7);
			$game = imagecreatefromgif($row2['image']); // Could be a Gif or Png
			$im = imagecreatefrompng($_GET['img']);
			//image.php?memberpic=".$_GET['id'
			if(!$im)
			{
				die("");
			}
			$font = "arial.ttf";
			$yellow = imagecolorallocate($im, 255, 255, 0);
			$black = imagecolorallocate($im, 0, 0, 0);
			$white = imagecolorallocate($im, 255, 255, 255);
			imagettftext($im, 10, 0, 165, 30, $white, $font, "Name: ".$row['username']);
			imagettftext($im, 10, 0, 165, 55, $white, $font, "Recruits: ".$row['recruits']);
			imagettftext($im, 10, 0, 165, 80, $white, $font, "Days In Clan: ".finddsl($row['joined']));
			imagettftext($im, 10, 0, 165, 105, $white, $font, "AIM: ".$row['aim']);
			imagettftext($im, 10, 0, 165, 130, $white, $font, "DSL: ".finddsl($row['timestamp']));

			imagettftext($im, 10, 0, 305, 30, $white, $font, "Main Game");
			imagecopymerge($im, $game, 325, 35, 24, 14, 24, 15, 100);
			//imagestring($im, 3, 165, 15, "TESTING", $white);
			header('Content-type: image/png');
			imagepng($im);
			imagedestroy($im);
		}
		else{
			die("The ID you submitted came back as 0 results");
		}
	}
	else{
		die("ID must be numeric!");
	}
}
else{
	die();
}
}
else{
die();
}
?>

 

 

 

EDIT i dono what x_src and y_src is but i just made them 0, 0 and it worked

thx for the help

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.