Isterklister Posted April 21, 2009 Share Posted April 21, 2009 Hello again, I have now picked up some code to merge two pictures (with transparency). <?php $flag = $_GET['flag']; /* Attempt to overlay transparent and semi-transparent images */ $width = 800; $height = 600; $dst_width = 800; $dst_height = 600; $bottom_image = imagecreatefrompng("flag-back.png"); $top_image = imagecreatefrompng('$flag'); imagesavealpha($top_image, false); imagealphablending($top_image, false); imagecopy($bottom_image, $top_image, 0, 0, 0, 0, $width, $height); header('Content-type: image/png'); $erer = 232; imagepng($bottom_image); imageDestroy($bottom_image); ?> I call the sript from another file: echo "<img src='merge_flag_logo.php?flag=$flag_t[flag]>"; The script works fine if I instead of $_GET... just write a picture name instead of $flag. How can I get the image name with GET and use it in the script? Thanks Isterklister Quote Link to comment https://forums.phpfreaks.com/topic/154965-solved-new-problem-with-gd-and-merge-two-images/ Share on other sites More sharing options...
taith Posted April 21, 2009 Share Posted April 21, 2009 i would say firstly, $top_image = imagecreatefrompng('$flag'); you need quotes on that, not 's... 's kill variables... it is looking for the file by the name of '$flag' not for the one specified in $_GET[flag]... Quote Link to comment https://forums.phpfreaks.com/topic/154965-solved-new-problem-with-gd-and-merge-two-images/#findComment-815123 Share on other sites More sharing options...
Isterklister Posted April 21, 2009 Author Share Posted April 21, 2009 Thanks, I have changed this but it is still not working. Quote Link to comment https://forums.phpfreaks.com/topic/154965-solved-new-problem-with-gd-and-merge-two-images/#findComment-815128 Share on other sites More sharing options...
taith Posted April 21, 2009 Share Posted April 21, 2009 The script works fine if I instead of $_GET... just write a picture name instead of $flag. How can I get the image name with GET and use it in the script? secondly, then i would guess, you have some complications in the file name that is being entered dynamically into the <img> tag... you may want to check for spaces, and whatnot and urlencode/urldecode to avoid that Quote Link to comment https://forums.phpfreaks.com/topic/154965-solved-new-problem-with-gd-and-merge-two-images/#findComment-815131 Share on other sites More sharing options...
.josh Posted April 21, 2009 Share Posted April 21, 2009 where is the $_GET var coming from? post that. Quote Link to comment https://forums.phpfreaks.com/topic/154965-solved-new-problem-with-gd-and-merge-two-images/#findComment-815155 Share on other sites More sharing options...
Isterklister Posted April 21, 2009 Author Share Posted April 21, 2009 I call the script via: echo "<img src='merge_flag_logo.php?flag=$flag_t[flag]>"; where (example) $flag_t[flag] = "flag2.png" Quote Link to comment https://forums.phpfreaks.com/topic/154965-solved-new-problem-with-gd-and-merge-two-images/#findComment-815225 Share on other sites More sharing options...
.josh Posted April 21, 2009 Share Posted April 21, 2009 I don't see a closing quote for your src='...' Also, in your script in your OP, did you try echoing out the GET var to make sure it has what you think it has? Quote Link to comment https://forums.phpfreaks.com/topic/154965-solved-new-problem-with-gd-and-merge-two-images/#findComment-815228 Share on other sites More sharing options...
Isterklister Posted April 21, 2009 Author Share Posted April 21, 2009 Thank you! It was the last ' in the scr='...' that was missing. I did test and change so much I missed that little thing. Quote Link to comment https://forums.phpfreaks.com/topic/154965-solved-new-problem-with-gd-and-merge-two-images/#findComment-815257 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.