Jump to content

Image Add Text

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
11 replies to this topic

#1
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
Okay i am trying to create a dynamic image. That gets info from a mysql and prints it out. (i have it done for the most part)

But my main question is. Can you put a image from the Mysql on another image?

#2
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
Yes

#3
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts

John said:

Yes
Sorry... xD
How do i do it?

Is there a built in function for it?

I know imagestring(); to do text

but thats about it

#4
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
imagecopymerge

Edited by John, 09 June 2009 - 01:43 PM.


#5
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts

Quote

You are not allowed to use that image extension on this board. A valid format is: Register a Domain, Find Hosting and Create a Website | Domain.com, an invalid format is: Register a Domain, Find Hosting and Create a Website | Domain.com

using
http://clanan.net/testy.php?id=155

EDIT:

i just did
http://clanan.net/te...155&img=gif.png

and it worked

#6
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
Does anyone know how to do a Specific font like Arial

#7
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
imagettftext

#8
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
Thanks i really appreciate it.

Now here is a big question i need help with..

I got a image on a image.. xD But how do i resize it to 100 x 100 from like 800x600 xD

#9
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
imagecopyresampled

I'm getting good at these one word responses. :)

#10
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
Do you know every function by heart or what? xD i tried searching for it

btw it didn't work for me

imagecopyresampled($im, $userimage, 30, 10, 0, 0, 100, 100, 100, 100);

http://clanan.net/te...img=sig_gen.png

#11
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts

Whitey said:

Do you know every function by heart or what?
I know a lot of them. Every time I go to php.net and look up a function, I always look at the list of functions on the left and click on one or two I'm not familiar with.

And I'm not sure why your invisible code isn't working.

#12
Whitey

Whitey

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 255 posts
<?php
error_reporting(E_ALL); 
include("config.php");
if(isset($_GET['id'])){
	if(isset($_GET['img'])){
		if(ctype_digit($_GET['id'])){
			$query = $config->query("SELECT * FROM `members` WHERE `id` = '".mysql_escape_string($_GET['id'])."'");
			if(mysql_num_rows($query) == 1){
				$row = mysql_fetch_array($query);
				$userpic = $row['picture'];
				$rank = $row['rank'];
				$rank = "images/".$rank.".jpg";
				$rank = imagecreatefromjpeg($rank);
				$result7 = $config->query("SELECT * FROM `games` WHERE ID = '".$row['game']."'");
				$row2 = mysql_fetch_array($result7);
				$explode = explode(".", $row2['image']);
				if(in_array("jpg", $explode)){
					$game = imagecreatefromjpeg($row2['image']);
				}
				elseif(in_array("png", $explode)){
					$game = imagecreatefrompng($row2['image']);
				}
				elseif(in_array("gif", $explode)){
					$game = imagecreatefromgif($row2['image']);			
				}
				else{
					die("The main game is not a png/jpg/gif!");
				}
				$userimage = imagecreatefromjpeg("http://clanan.net/image.php?memberpic=".mysql_escape_string($_GET['id']));
				
				$im = imagecreatefrompng("images/".$_GET['img']);
				//image.php?memberpic=".$_GET['id'
				if(!$im)
				{
					die("");
				}
				$font = "arial.ttf";
				$yellow = imagecolorallocate($im, 255, 255, 0);
				$black = imagecolorallocate($im, 0, 0, 0);
				$white = imagecolorallocate($im, 255, 255, 255);
				imagettftext($im, 10, 0, 165, 30, $white, $font, "Name: ".$row['username']);
				imagettftext($im, 10, 0, 165, 55, $white, $font, "Recruits: ".$row['recruits']);
				imagettftext($im, 10, 0, 165, 80, $white, $font, "Days In Clan: ".finddsl($row['joined']));
				imagettftext($im, 10, 0, 165, 105, $white, $font, "AIM: ".$row['aim']);
				imagettftext($im, 10, 0, 165, 130, $white, $font, "DSL: ".finddsl($row['timestamp']));
				
				imagettftext($im, 10, 0, 305, 30, $white, $font, "Main Game");
				imagecopymerge($im, $game, 325, 35, 0, 0, 28, 14, 100);
				imagecopymerge($im, $rank, 15, 115, 0, 0, 130, 25, 100);
				imagecopyresampled($im, $userimage, 30, 10, 0, 0, 100, 100, 100, 100);
				//imagecopymerge($im, $userimage, 30, 10, 0, 0, 100, 100, 100);
				//imagestring($im, 3, 165, 15, "TESTING", $white);
				header('Content-type: image/png');
				imagepng($im);
				imagedestroy($im);
			}
			else{
				die("The ID you submitted came back as 0 results");
			}
		}
		else{
			die("ID must be numeric!");
		}
	}
	else{
		die();
	}
}
else{
	die();
}
?>

Here is the full code xD