Page 1 of 1

How to get merged tile to display with img src?

Posted: Sun Jul 19, 2009 1:12 am
by psychotomus
so I have

Code: Select all

<img src="mergetile.php?name=gamepath&tile=tilename&char=charname">
doesn't work with my code below.


my code to merge image which works if i go to page

Code: Select all

<?
include "mysql.php";
$name = mysql_real_escape_string($_GET['name']);
$tile = mysql_real_escape_string($_GET['tile']);
$char = mysql_real_escape_string($_GET['char']);
 
$src = imagecreatefrompng("games/$name/chars/$char");
$dest = imagecreatefrompng("games/$name/tiles/$tile");
 
// Copy and merge
imagecopymerge($dest, $src, 0, 0, 0, 0, 32, 32, 50);
 
// Output and free from memory
header('Content-Type: image/png');
 
imagepng($dest);
 
imagedestroy($dest);
imagedestroy($src);
?>

Re: How to get merged tile to display with img src?

Posted: Sun Jul 19, 2009 4:52 am
by jazz090
i have a few theories:

1. although you can have images in html without the width and height attribute, its good practice to include them. if the images are being cached and image sizes of different, browser may treat them as 0px by 0px.
2. why are you escaping with mysql_real_escape_string()? you are not uploading or downloading from database so it may cause a fatal error and why the image is not being displayed. remove the image/png header and run the image script alone to see if its any errors are coming back
3. make sure your script is working correctly to begin with. i.e. without parameters in its simplest form.

Re: How to get merged tile to display with img src?

Posted: Sun Jul 19, 2009 5:03 am
by kaszu
My theory: mergetile.php is not in the same folder where is html file (with <img> tag)

Re: How to get merged tile to display with img src?

Posted: Sun Jul 19, 2009 6:00 am
by jazz090
kaszu wrote:My theory: mergetile.php is not in the same folder where is html file (with <img> tag)
that kind of error is very obvious because the browsers show it as an image space with a big red cross in it and if it has an alt tag, the content of the alt tag is also displayed. also not to be picky but you are not following html standards. the image tag needs to be closed with /> and not just > alone. different browsers may interpret this differently.

Re: How to get merged tile to display with img src?

Posted: Sun Jul 19, 2009 10:12 am
by kaszu
<img src="..." alt=""> is not valid in XHTML, but it is in HTML

Re: How to get merged tile to display with img src?

Posted: Sun Jul 19, 2009 5:06 pm
by psychotomus
jazz090 wrote:i have a few theories:

1. although you can have images in html without the width and height attribute, its good practice to include them. if the images are being cached and image sizes of different, browser may treat them as 0px by 0px.
2. why are you escaping with mysql_real_escape_string()? you are not uploading or downloading from database so it may cause a fatal error and why the image is not being displayed. remove the image/png header and run the image script alone to see if its any errors are coming back
3. make sure your script is working correctly to begin with. i.e. without parameters in its simplest form.

I made sure the script was working without including in my html first. works like a charm till i try to show it with my img tag

Re: How to get merged tile to display with img src?

Posted: Tue Jul 21, 2009 7:04 pm
by psychotomus
still ooking for the answer =(

Re: How to get merged tile to display with img src?

Posted: Thu Jul 23, 2009 8:48 pm
by psychotomus
nobody?