Image Editing
hi, i have a image which i want to overlay dynamic text and then save it as a .png or .gif how would i go about, ive had alook round php.net but not sure what to search for, example below
PHP Code:
$img = 'test.png' ;
$text = 'Created by ' . $name ;
PHP:4,5
Thanks
Originally Posted by
gavshouse
hi, i have a image which i want to overlay dynamic text and then save it as a .png or .gif how would i go about, ive had alook round php.net but not sure what to search for, example below
PHP Code:
$img = 'test.png' ;
$text = 'Created by ' . $name ;
PHP:4,5
Thanks
Assuming you compiled PHP with GD support, you can use the GD2 functions .
ive looked into that but i cant find a function that will write text on a image, just to create a image with text
ive found what i want but i get a error, whats the full path to the font file ive tried this but i get that error.
PHP Code:
$font = imagepsloadfont ( $_SERVER [ 'DOCUMENT_ROOT' ]. '/font.pfm' );
PHP Code:
Fatal error : Call to undefined function imagepsloadfont () in / home / fhlinux159 / p / ps3 . gavssite . com / user / htdocs / test / test . php on line 11
Full Code
PHP Code:
<?php // Create image handle $im = imagecreatefrompng ( $_SERVER [ 'DOCUMENT_ROOT' ]. '/test/test.png' ); // Allocate colors $black = imagecolorallocate ( $im , 0 , 0 , 0 ); $white = imagecolorallocate ( $im , 255 , 255 , 255 ); // Load the PostScript Font $font = imagepsloadfont ( $_SERVER [ 'DOCUMENT_ROOT' ]. '/font.pfm' ); // Write the font to the image imagepstext ( $im , 'Sample text is simple' , $font , 12 , $black , $white , 50 , 50 ); // Output and free memory header ( 'Content-type: image/png' ); imagepng ( $im ); imagedestroy ( $im ); ?>
im using this http://uk2.php.net/manual/en/functio...atefrompng.php
imagepsloadfont() Problems
im having problems with this GD function
for full story and code refer to my previous post
http://www.webdeveloper.com/forum/sh...d.php?p=967144
code snippet
PHP Code:
<?php
// Create image handle
$im = imagecreatefrompng ( $_SERVER [ 'DOCUMENT_ROOT' ]. '/test/test.png' );
// Allocate colors
$black = imagecolorallocate ( $im , 0 , 0 , 0 );
$white = imagecolorallocate ( $im , 255 , 255 , 255 );
// Load the PostScript Font
$font = imagepsloadfont ( $_SERVER [ 'DOCUMENT_ROOT' ]. '/font.pfm' );
// Write the font to the image
imagepstext ( $im , 'Sample text is simple' , $font , 12 , $black , $white , 50 , 50 );
// Output and free memory
header ( 'Content-type: image/png' );
imagepng ( $im );
imagedestroy ( $im );
?>
Documentation
http://uk2.php.net/manual/en/functio...atefrompng.php
please do not repost threads if you haven't had it resolved. we don't discourage bumping.
anyways, I think you should look at this link, since your error is with loading fonts
http://uk2.php.net/manual/en/functio...psloadfont.php
specifically this note:
Note: This function is only available if PHP is compiled using --with-t1lib[=DIR].
Did you in fact compile php with t1lib?
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Bookmarks