Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/257424-difficulty-layering-objects/
Share on other sites

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?

 

 

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.

 

 

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.