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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.