View Full Version : Resolved Rotate text 30degrees or more?

03-26-2009, 05:46 PM
Hi guys,

I wonder if it is possible to rotate a piece of text with PHP?

I have searched around on google and found only IE-solutions and solutions saying that I have to write the text to an image and then rotate it with some GD-library or something. But my problem is that my text is a PHP-date script which changes output every day, - that's why I can not just make it an image.

Does anyone know how to get around that one? :confused::confused:

03-26-2009, 05:57 PM
solutions saying that I have to write the text to an image and then rotate it with some GD-library or something
you would use that to generate that img on page load... so it's not like it's a static img or something. think of a captcha solution for example.

03-27-2009, 11:48 AM
Thank you.

I've now found and modified a possible solution which generates an image with some text and sets a background-color. However, how would I modify it to not set a background-color but write the text on top of an image instead?

<?php header("Content-Type: image/jpeg"); create_image();
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
//Send a generated image to the browser

function create_image()

$pass = Patrick;

//Set the image width and height
$width = 100;
$height = 20;

//Create the image resource
$image = ImageCreate($width, $height);

//We are making three colors, white, black and gray
$white = ImageColorAllocate($image, 255, 255, 255);
$black = ImageColorAllocate($image, 0, 0, 0);
$grey = ImageColorAllocate($image, 204, 204, 204);

//Make the background black
ImageFill($image, 0, 0, $black);

//Add generated string in white to the image
ImageString($image, 3, 30, 3, $pass, $white);

//Output the newly created image in jpeg format

//Free up resources


I guess this is the part which needs to be modified in some way:

//Make the background black
ImageFill($image, 0, 0, $black);

03-27-2009, 12:58 PM
Nevermind, I figured it out. You have to replace the 'image' variable with the "createimagefrompng":

$image = ImageCreatefrompng("captcha.png");

I also found this: http://www.alistapart.com/articles/dynatext