Rotator
Members-
Content Count
6 -
Joined
-
Last visited
About Rotator
-
Rank
Newbie
-
Okay, new question:With the current code, I have to manually changed the left indent of the text whenever I edit it, to make sure it's centered on the image...Isn't there a way to automatically ensure that the text is centered?
-
Well, I never worked with Cascading Style Sheets (CSS) before, so that would be a question for someone else Sorry.
-
Thanks alot, guys! I finally got the look I was searching for. Had to tweak the code alot, but it works now... <?phpheader("Content-type: image/png");$select = rand(1,3);if($select==1)$string1 = "Achievement Status";if($select==1)$string2 = "4395 Gamerpoints";if($select==2)$string1 = "Latest Game";if($select==2)$string2 = "Gears of War";if($select==3)$string1 = "Latest Achievement";if($select==3)$string2 = "Veteran of D Day";if($string1=="Achievement Status")$I1 = "65";if($string2=="4395 Gamerpoints")$I2 = "74";if($string1=="Latest Game")$I1 = "97";if($string2=="Gears of War")$I2 = "87";if($string1=="Latest Achievement")$I1 = "66";if($string2=="Veteran of D Day")$I2 = "72";$i = 14;$font = "lcd.ttf";$size = imagettfbbox($i, 0, $font, $string);$im = @imagecreate(300, 80) or die("Cannot Initialize new GD image stream");$bgcolor = imagecolorallocate($im, 0, 64, 0);$text_color = imagecolorallocate($im, 0, 255, 0);$text_color2 = imagecolorallocate($im, 0, 128, 0);imagettftext($im, $i, 0, 5, 20, $text_color2, $font, "88888888888888888888888888888"); imagettftext($im, $i, 0, 70, 20, $text_color, $font, "COLLECTION STATUS"); imagettftext($im, $i, 0, 5, 38, $text_color2, $font, "88888888888888888888888888888"); imagettftext($im, $i, 0, 39, 38, $text_color, $font, "48 RETAIL XBOX360 TITLES");imagettftext($im, $i, 0, 5, 56, $text_color2, $font, "88888888888888888888888888888"); imagettftext($im, $i, 0, $I1, 56, $text_color, $font, $string1); imagettftext($im, $i, 0, 5, 74, $text_color2, $font, "88888888888888888888888888888"); imagettftext($im, $i, 0, $I2, 74, $text_color, $font, $string2);imagepng($im);imagedestroy($im);?> Giving me that following image with the first two lines static and the other two random
-
Now, how can I get to see your code? If you'll let me? :blink:The first code I wrote didn't have any information about the font, because I didn't know what to do...But as I said, I tried imagettftext in conjunction with $font, but to no avail...
-
I tried replacing imagestring with imagettftext and adding $font = 'lcd.ttf';. The lcd.ttf is uploaded to the same dir. I see the image as it's supposed to look, but no text...
-
Hey Having browsed this and other sites I've come up with the following signature-code for generating text on an image: <?php header("Content-type: image/png"); $select = rand(1,3);if($select==1)$img = "gow.png";if($select==2)$img = "gow2.png";if($select==3)$img = "gow3.png";$image = imagecreatefrompng("$img");//imagecolorallocate($image, R, G, B) in HEX values$font_white = imagecolorallocate($image, 255, 255, 255);$font_grey = imagecolorallocate($image, 128, 128, 128);$select = rand(1,3);if($select==1)$string1 = "Achievement Status";if($select==1)$string2 = "4395 Gamerpoints";if($select==2)$string1 = "Latest Game";if($select==2)$string2 = "Gears of War";if($select==3)$string1 = "Latest Achievement";if($select==3)$string2 = "Veteran of D-Day (Call of Duty 2)";//($image, fontsize, rightindent, downindent, data, txtcolour)imagestring($image, 3, 7, 5, "Collection Status", $font_white);imagestring($image, 3, 7, 23, "48 Retail Xbox360 Titles", $font_white);imagestring($image, 3, 7, 41, $string1, $font_white); imagestring($image, 3, 7, 59, $string2, $font_white); imagepng($image); imagedestroy($image); ?> However, it generates the text in the image in a standard font. Is there a way to make it use a different truetype font, one located on the same server as the php, but not installed on the hostmachine? I'm REALLY new to php, so please reply in plain english Thanks in advance.