neugi Posted July 2, 2006 Share Posted July 2, 2006 Hi, i want to use this code to write a text to a img, but it din't work and i don't know why.[code] $font = "rabiohead.ttf"; $grund_bild = "barcode.gif"; $winkel = "90"; $text = "test"; $img = imagecreatefromgif($grund_bild); $black = imagecolorallocate($img, 0,0,0); imagettftext($img, 10, $winkel, 0, 0, $black, $font, $text); header("Content-type: image/gif"); imagegif($img); imagedestroy($img);[/code]myabe someone can find the problem.thx Link to comment https://forums.phpfreaks.com/topic/13441-write-text-in-image/ Share on other sites More sharing options...
Barand Posted July 2, 2006 Share Posted July 2, 2006 is the font file "rabiohead.ttf" in same folder as script?Comment out the header() and run script to show error messages Link to comment https://forums.phpfreaks.com/topic/13441-write-text-in-image/#findComment-51926 Share on other sites More sharing options...
neugi Posted July 2, 2006 Author Share Posted July 2, 2006 is in the same direktory ;)and if the header is away there is no error message, i've checked this already. best Link to comment https://forums.phpfreaks.com/topic/13441-write-text-in-image/#findComment-51927 Share on other sites More sharing options...
Barand Posted July 2, 2006 Share Posted July 2, 2006 try moving the text (baseline) coords further down the image so text is inside the image Link to comment https://forums.phpfreaks.com/topic/13441-write-text-in-image/#findComment-51928 Share on other sites More sharing options...
redarrow Posted July 2, 2006 Share Posted July 2, 2006 this is a png version ok and tested//<?php//header("Content-type: images/png");//$string = "hi";//$im = imagecreatefrompng("images/banner.png");//$orange = imagecolorallocate($im, 220, 210, 60);//$px = (imagesx($im) - 7.5 * strlen($string)) / 2;//imagestring($im, 3, $px, 9, $string, $orange);//imagepng($im);//imagedestroy($im);//?> Link to comment https://forums.phpfreaks.com/topic/13441-write-text-in-image/#findComment-51940 Share on other sites More sharing options...
neugi Posted July 2, 2006 Author Share Posted July 2, 2006 thx worked Link to comment https://forums.phpfreaks.com/topic/13441-write-text-in-image/#findComment-51951 Share on other sites More sharing options...
redarrow Posted July 2, 2006 Share Posted July 2, 2006 I have spent ages on your code but sorry can not get the gof to work like the png sorry.all the best. Link to comment https://forums.phpfreaks.com/topic/13441-write-text-in-image/#findComment-51953 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.