Jump to content

[SOLVED] Urgent GD Image question needs answeriing.


Recommended Posts

Hiya im workin on my own php image (first one ever) and with a help of a few tutorials i hav come up with...

www.ragingmortals.com/tester.php

 

What i need to do is put another image like...

www.ragingmortals.com/images/characters/any image in this directory

onto my php made image.

 

Just wondering how i could do that.

 

If you have enough time could you please add it onto this script and explain for me? Thanks...

 

p.s. im currently working on the page so plz refresh if their are errors.

<?
//CREATED BY WASIM ILYAS!<-- THATS ME! ILYAS THE GREAT 

header ("Content-type: image/gif");
$im= imagecreatefromgif("images/user.gif"); //Image i want to use
$color = imagecolorallocate($im, 255,255,255); //Text color set to white
$txt = (imagesx($im) - 260); //Text will be on the positions (-260 the image width).
$txt2 = (imagesx($im) - 390);
imagestring($im, 3, $txt, 15, "Hi guys im still making this image", $color);
imagestring($im, 3, $txt, 30, "so Please...leave  now", $color);
imagestring($im, 3, $txt2, 15, "Another img to", $color);
imagestring($im, 3, $txt2, 30, "be put here", $color);

imagegif($im);
imagedestroy($im);

?>

<?php

$bg = './images/example.png';//url->img ex: (www/images/example.png)

$img = imagecreatefrompng($bg);//creates img from file

header('Content-type: image/png');

imagepng($img);//output

?>

 

maybe this helps:

http://at2.php.net/manual/en/function.imagecreatefrompng.php

ummm i dont think that'll help...

what im trying to do is create a picture ontop of the other picture (so both pictures are still showing) and then use then position the second picture somewhere on the first picture. ive already made the first picture (which is on the code i specified) now i need to make a second picture_.

Okay come up with an error...

www.ragingmortals.com/tester.php

 

New code:

<?

//CREATED BY WASIM ILYAS!<-- THATS ME! ILYAS THE GREAT ;)

require_once "includes/db_connect.php";

session_start();

$query= mysql_query("SELECT * FROM users WHERE username='$username'");

header ("Content-type: image/gif");

$im= imagecreatefromgif("images/user.gif"); //Image i want to use

$color = imagecolorallocate($im, 255,255,255); //Text color set to white

$txt = (imagesx($im) - 260); //Text will be on the positions (-260 the image width).

$txt2 = (imagesx($im) - 390);

imagestring($im, 3, $txt, 15, "Hi guys im still making this image", $color);

imagestring($im, 3, $txt, 30, "so Please...leave >:( now", $color);

imagestring($im, 3, $txt2, 15, "Another img to", $color);

imagestring($im, 3, $txt2, 30, "be put here", $color);

imagestring($im, 3, $txt, 45, "$username", $color);

 

$secondim= imagecreatefromgif("images/characters/rmchar5.gif");

imagecopymerge($im, $secondim, 0, 0, 15, 15);;

 

imagegif($im);

imagedestroy($im);

?>

okay as your not telling us the error i'll guess..

its on this line

imagecopymerge($im, $secondim, 0, 0, 15, 15);; //<-Right ?

Now i can see 2 problems with that..

 

1. you have 2 ;;'s

2. read the manual for the

imagecopymerge

 

 

sorry but if you won't make an effort then why should i!

Hmm any their? :P

Okay I have another problem now...

www.ragingmortals.com/tester.php

 

How do i get rid of the black part?

 

This should have the desired effect (you need to add in the database parts and file locations yourself)

 

<?php

header ("Content-type: image/gif");
$im= imagecreatefromgif("user.gif"); //Image i want to use
$color = imagecolorallocate($im, 255,255,255); //Text color set to white
$txt = (imagesx($im) - 260); //Text will be on the positions (-260 the image width).
$txt2 = (imagesx($im) - 390);
imagestring($im, 3, $txt, 15, "Hi guys im still making this image", $color);
imagestring($im, 3, $txt, 30, "so Please...leave Angry now", $color);
imagestring($im, 3, $txt, 45, $username, $color);

$secondim= imagecreatefromgif("rmchar5.gif");
imagecopymerge($im, $secondim, 10, 15, 0, 0, 71, 146, 100);

imagegif($im);
imagedestroy($im);
?>

 

the black part was to do with this part:

 

imagecopymerge($im, $secondim, 0, 0, 15, 15, 71, 146, 100);

 

The code I have there gives this output:

 

char.gif

 

Sam

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.