Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GD Library Text on Image

Status
Not open for further replies.

overflo

Technical User
Feb 10, 2003
70
AU
The following is some code that was supplied to me by a Tek-Tips member (pjadie - thanks again) which works great except when I try to save it to file. I have tried to add to the imagepng($im);
with this
imagepng($im, 'new_image.png', 100);
i have also tried by declaring a $new_image variable but it won't work.

Any ideas???

Cheers


Code:
<?php

//get tektips logo
$im = imagecreatefromgif('[URL unfurl="true"]http://www.tek-tips.com/images/logo.gif');[/URL]

//get the image size
$w = imagesx($im);
$h = imagesy($im);

//now create the text on a new canvas (i've used identical sized canvases but in practice you probably will not want to do so)
$text = imagecreatetruecolor($w, $h);
//place some text at the top left
imagestring($text, 5, 0, 0, 'Tek-Tips', 0x0000FF);


// merge the two canvas
//set opacity to 50%
imagecopymerge($im, $text, 0, 0, 0, 0, $w, $h, 50);

// output the image
header('Content-Type: image/png');
imagepng($im);
imagedestroy ($text);
imagedestroy($im);
?>
 
Sorry - the member that supplied the code was jpadie (not pjadie - sorry)
 
i don't think 100 will work as a value. it should be between 0 and 9.

try this
Code:
error_reporting (E_ALL); ini_set('error_display', true);
imagepng($im, 'new_image.png', 0);

if that does not work then ensure that the current working directory is writable by the php process.
 
Before I put the error_reporting line in it prints the web address on the page, after the error_reporting line nothing.
 
sorry the ini_set should be for display_errors
Code:
ini_set('display_errors', true);
 
Getting this error
Warning: imagepng() [function.imagepng]: Unable to open 'new_img.png' for writing: Permission denied in /lecturers/brockk/ on line 89
 
as I said above
me said:
if that does not work then ensure that the current working directory is writable by the php process.
clearly the directory is NOT writable by php. you need to change this although it may be that your host does not permit such a change.
This is a file-system issue.
 
changed to 777 all working now. Once again thankyou for your help.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top