|
||||||||||||||
|
||||||||||||||
| Comments |
| jayaraj posted on May 8, 2009, 10:46 am |
| i got this error Warning: imagettftext() [function.imagettftext]: Invalid font filename after Change the path name $font = 'C:\WINDOWS\Fonts\arial.ttf'; problem is solved, working well |
| Ben Clay posted on April 1, 2009, 10:48 pm |
| Thanks for having a link to the arial.ttf. |
| Mark posted on January 16, 2009, 2:31 am |
| I tried to run this script but got nothing but a blank screen on my browser. I have GD enabled on the server (i found that using phpinfo()). arial.ttf is in the same folder as that of script, so is the image. Here's my script <? $SourceFile = '/www/image1.jpg'; $WaterMarkText = '12345'; function watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile) { list($width, $height) = getimagesize($SourceFile); $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($SourceFile); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height); $black = imagecolorallocate($image_p, 0, 0, 0); $font = 'arial.ttf'; $font_size = 10; imagettftext($image_p, $font_size, 0, 10, 20, $black, $font, $WaterMarkText); echo $SourceFile; if ($DestinationFile<>'') { imagejpeg ($image_p, $DestinationFile, 100); } else { header('Content-Type: image/jpeg'); imagejpeg($image_p, null, 100); }; imagedestroy($image); imagedestroy($image_p); }; ?> Any idea what is wrong? Please help |
| Jim posted on December 2, 2008, 1:03 am |
| Hi. I have PHP and GD (bundled (2.0.28 compatible) on my server but I get a blank screen with this script. Any ideas? |
| Noel posted on November 26, 2008, 2:12 pm |
| Do I have to have something installed on my server as when I put that code in, nothing happens, it gives me a blank screen -------------- Veselin: yes you need PHP with GD support and the code correctly placed. |
| silva posted on November 15, 2008, 2:32 pm |
| hi, i have already check this coding.but it will display like this error:"Warning: imagettftext() [function.imagettftext]: Invalid font filename in C:xampphtdocssamplewatermarkwatersample3.php on line 20". but all files are in one folder.arial.ttf also in the same folder. so, pls help me to solve this.thanks |
| silva posted on November 15, 2008, 12:49 pm |
| This is great script . I'm working in local host now , where i should upload the font file .i already download the arial.ttf and save in script folder. when i run this script, i got warning message like this: " Warning: imagettftext() [function.imagettftext]: Invalid font filename in C:xampphtdocssamplewatermarkwatersample3.php on line 20 ". but destinatiion place have a image without watermark text. so, pls, help me.how to display the watermark text on the destination place.ok bye ------------------ Veselin: the file should be in the same folder where your PHP files are |
| Loo posted on October 6, 2008, 3:28 pm |
| This is brilliant, exactly what I was looking for. I did mod it slightly as I wanted the watermark through the middle of the image (it's easy to cut the edge off with the watermark on) so I used the following: list($width, $height) = getimagesize($SourceFile); $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($SourceFile); $left = ($width / 7) ; $top = ($height / 3) ; $bot = ($top * 2) ; imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height); $black = imagecolorallocatealpha($image_p, 255, 255, 255, 50); $font = 'arial.ttf'; $font_size = 10; imagettftext($image_p, $font_size, 0, $left, $bot, $black, $font, $WaterMarkText); I had a website address to watermark, hence the margin from the left being small. Thanks to everyone who has contributed here, you saved me a lot of headaches. |
| Diaa Bendary posted on September 13, 2008, 4:23 pm |
| This is great script . I'm working in local host now , where i should upload the font file . If you can make this script with watermark photo instead of font Best regards ---------- Veselin: it should be in the same folder where your PHP script is |
| Khawaja Abid posted on August 13, 2008, 11:14 am |
| I utilized the above code it was really great and help me alot i really thank full to you and pawan asked for image on image for that please use this may its help $dest = imagecreatefromjpeg('2.jpg'); $src = imagecreatefromgif('php2.gif'); imagecopymerge($dest, $src, 0, 0, 0, 0, 800, 600, 75); header('Content-Type: image/gif'); hope this help you all thanks |