Page 1 of 1

adding text on an already made image

Posted: Sat Apr 03, 2004 9:16 am
by JohnDigweed
Hi,

I have a business card site, and I want to have users to be able to add text on the business card image to see what it looks like.

First, I need to know how to add text on an already made image. Its a white business card :

<?
header ("Content-type: image/jpg");
$image = imagecreatefromjpeg ("blank.jpg");
$black = imagecolorresolve ($image, 0, 0, 0);
imagettftext ($image, 20, 0, 10, 20, $black, "Test Text");
imagejpeg($image,'',90);
imagedestroy($image);
?>

However, I see only the picture. No text! I dont know whats wrong!

I would be thankful for any help. :)

Posted: Sat Apr 03, 2004 1:04 pm
by PrObLeM

Code: Select all

header("Content-type: image/jpeg");
 $fontname = "arial";
 $fontsize = 12;
 $im = imagecreate(400,30);
 $white = imagecolorallocate($im, 255,255,255);
 $black = imagecolorallocate($im, 0,0,0);
 $text = "Hello world";
 imagettfbbox($im, $fontsize, 0, 0, 0, $white, $fontname, $text);

Posted: Sat Apr 03, 2004 3:46 pm
by JohnDigweed
Hi,

ok Thanks for that. How would I add that ontop of an already made image?

Thanks.

Posted: Sun Apr 04, 2004 9:50 am
by JohnDigweed
Can anyone help? my script that I posted at the top will not work. No text will show.

Thanks.

Posted: Sun Apr 04, 2004 10:03 am
by markl999

Code: Select all

<?php
header ("Content-type: image/jpg");
$image = imagecreatefromjpeg ("blank.jpg");
$black = imagecolorresolve ($image, 0, 0, 0);
imagettftext ($image, 20, 0, 10, 20, $black, 'arial.ttf', 'Test Text');
imagejpeg($image,'',90);
imagedestroy($image);
?>
.. works for me :o

Posted: Sun Apr 04, 2004 10:45 am
by JohnDigweed
Could it possibly be the JPEG im using?

Also, does the TTF have to be uploaded to my web site?

is IMage color resolve same thing as imageallocate?

Thanks :)