aebstract Posted November 24, 2008 Share Posted November 24, 2008 <?php $file = 'image.jpg'; $image = imagecreatefromjpeg($file); list($width, $height) = getimagesize($file); $font = 'arial.ttf'; $size = 8; $title = 'Last played:'; $artist = 'artist name'; $song = 'song name'; $colorHex = '000000'; list($tr, $tg, $tb) = sscanf($colorHex, '%02X%02X%02X'); $textColor = imagecolorallocate($image, $tr, $tg, $tb); imagettftext($image, $size, 0, 4, $height-29, $textColor, $font, trim($title)); imagettftext($image, $size, 0, 4, $height-17, $textColor, $font, trim($song)); imagettftext($image, $size, 0, 4, $height-5, $textColor, $font, trim($artist)); imagejpeg($image, 'image2.jpg', 95); ?> Trying to place text on top of an existing image and create a new image from that. Once I figure out how to reference values from another website, it should be able to update automatically with certain bits of information.. as it changes on that site. Right now it isn't working really at all. Could someone possibly help on this? Link to comment https://forums.phpfreaks.com/topic/134054-trying-to-place-text-on-an-image/ Share on other sites More sharing options...
ShiloVir Posted November 24, 2008 Share Posted November 24, 2008 hows this?: <?php //use existing image as a canvas $myImage = ImageCreateFromPNG ("baseimage.png"); //allocate the color white $white = ImageColorAllocate ($myImage, 255, 255, 255); //draw on the new canvas ImageFilledEllipse($myImage, 100, 70, 20, 20, $white); ImageFilledEllipse($myImage, 175, 70, 20, 20, $white); ImageFilledEllipse($myImage, 250, 70, 20, 20, $white); //output the image to the browser header ("Content-type: image/png"); ImagePNG($myImage); //clean up after yourself ImageDestroy($myImage); ?> Link to comment https://forums.phpfreaks.com/topic/134054-trying-to-place-text-on-an-image/#findComment-697959 Share on other sites More sharing options...
aebstract Posted November 24, 2008 Author Share Posted November 24, 2008 Didn't do anything :/ Link to comment https://forums.phpfreaks.com/topic/134054-trying-to-place-text-on-an-image/#findComment-697987 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.