...

View Full Version : Adding Text to Image - Resizing Text etc... (Image Chef)



x3boost
08-13-2008, 09:41 PM
I'm trying to make an Image-Chef like PHP function. Currently I have this


<?php

header("Content-type: image/png");
$string = $_GET['text'];
$im = imagecreatefrompng("Egypt.png");
$orange = imagecolorallocate($im, 219, 181, 1);
$black = imagecolorallocate($im, 0, 0, 0);
$px = (imagesx($im) + 16 * strlen($string)) / 2;
imagestring($im, 26, $px, 48, $string, $black);
imagestring($im, 25, $px, 47, $string, $orange);
imagepng($im);
imagedestroy($im);

?>


This allows the production of an image with the text I input in the Url (in fore color and with a shadow) lying over the base image provided. The intention is just a small thing similar to imagechef.com where I can enter small amounts of text and incorporate it directly onto the image. The thing I am struggling with primarily is resizing the text based on the length of the string.

Basically, on image chef, there is a defined width that the text can occupy. If the text occupies more that this width it is scrunched together to fit. Is it possible to do this here? Any suggestions on improvement?



Thanks.

x3boost
08-19-2008, 07:49 PM
Anyone have any ideas?

Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum