Jump to content

Create image from xml - style the text


graves_it

Recommended Posts

Here is the script the reads a twitter xml feed and generates a png from the first tweet. What I want to be able to is specify a width so the text will wrap and be able to position the text within a certain dimensions. I created the files with a base image because I didn't know how to create an image with a specific color. So removing the base image section would be great. Lastly, I would like to style the font with a certain font and weight.

 

<?php
// Get the XML data from Feedburner
$sxe = new SimpleXMLElement('twitter.xml', NULL, TRUE);
$tweet = $sxe->status[0]->text;

// Create the image from the base image
$img = imagecreatefrompng('tweet-base.png');
$color = imagecolorallocate($img, 0x33, 0x33, 0x33);
imagestring($img, 2, $xpos, 2, $tweet, $color);

// Save the image
imagepng($img, 'tweet.png');
?>

Link to comment
https://forums.phpfreaks.com/topic/211130-create-image-from-xml-style-the-text/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.