Lynx992 Posted February 21, 2012 Share Posted February 21, 2012 Hello everyone. Before I start, I'm relivily new to PHP but have been doing it for a few weeks or so, my latest problem that i've been trying to crack for a few days now is using the "imagecopy" command in php, I'm working on an avatar script that lets users design there own avatar, selecting clothes, hair, eyes, etc. I've only just started and i've ran into a rather large problem so don't seem to be able to move any further, This is the code i have <?php ob_start (); /* background */ $bg = imagecreatefrompng('bg.png'); /* foreground */ $fg = imagecreatefrompng('fg.png'); /* frontground */ $fgg = imagecreatefrompng('fgg.png'); $x = imagesx($bg); $y = imagesy($bg); imagecopy($bg, $fg, $fgg, $x, $y); header('Content-Type: image/png'); imagepng($bg); imagedestroy($bg); imagedestroy($fg); imagedestroy($fgg); ?> However for some reason, probably a simple fault, it's just giving me a broken image link? I'm not sure why it's doing this if you want to see exactly what it's doing please look at http://chat.blastgames.org/index.php Like i say i'm clueless so any help would be much appreciated, Also if anyone knows of any downloadable php avatar scripts that lets you customize things like hair, clothes etc. please tell me, I've been searching for one for a while, Thanks for reading , Any help will be much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/257424-difficulty-layering-objects/ Share on other sites More sharing options...
jcbones Posted February 21, 2012 Share Posted February 21, 2012 Remove ob_start(); You are not flushing it, neither do you need it, that may be the problem. Quote Link to comment https://forums.phpfreaks.com/topic/257424-difficulty-layering-objects/#findComment-1319399 Share on other sites More sharing options...
Lynx992 Posted February 21, 2012 Author Share Posted February 21, 2012 I'm getting a few more errors now, and sorry for the slow reply there Warning: Wrong parameter count for imagecopy() in /home/blastgam/public_html/chat/index.php on line 14 Warning: Cannot modify header information - headers already sent by (output started at /home/blastgam/public_html/chat/index.php:14) in /home/blastgam/public_html/chat/index.php on line 16 ‰PNG IHDRúKÖ ºMIDATxœíÁ1 õOm O àlÜ!>]IEND®B`‚ That's the erros, Line 14: imagecopy($bg, $fg, $fgg, $x, $y); Also really not sure what all those random charter's at the bottom are but i seem to see them a lot while i'm trying to get this working? Anyone know a fix for these? Quote Link to comment https://forums.phpfreaks.com/topic/257424-difficulty-layering-objects/#findComment-1319515 Share on other sites More sharing options...
jcbones Posted February 21, 2012 Share Posted February 21, 2012 There are 8 arguments to pass to image copy. imagecopy. **Note: you will have to use imagecopy() twice to overlay 2 images. You are getting header errors, due to the errors being output to the screen. The random characters is the output of the image, because of the errors sending the headers before the header call, the image is outputting as HTML. Fix the errors, you will fix the header and the random character isssue. Quote Link to comment https://forums.phpfreaks.com/topic/257424-difficulty-layering-objects/#findComment-1319739 Share on other sites More sharing options...
Lynx992 Posted February 24, 2012 Author Share Posted February 24, 2012 Thanks a lot bro! I'll try and do it now, thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/257424-difficulty-layering-objects/#findComment-1320601 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.