I know.. this is using PHP GD.
And its making me mad![]()

I know.. this is using PHP GD.
And its making me mad![]()
I'm assuming there's an image for each character, which are then joined using the imagecopymerge function. It's pretty simple, you'll just need to get the width of each character, add it together, create the image and then place each character (you could do it with a foreach loop).
kinda quit.
Could you help joshua?
Im not a noob at this but I just haven't worked with GD that much
I'll write a basic script you can ammend to fit your needs.
I had a similar script I wrote for someone else which I could structure it around:
File "config.php":PHP Code:<?php
require ('config.php');
header("Content-type: image/png");
// Check Message
if(preg_match("/^[a-zA-Z0-9 ]{0,30}$/", $_GET['message']) && !empty($_GET['message'])) {
$chars = str_split(str_replace(' ', '_', $_GET['message']));
} else {
$chars = str_split('Invalid_Message');
}
// Assign font variable
$fontDirectory = $fonts[$_GET['font']];
if($fontDirectory == '') $fontDirectory = 'test';
// Count size and create images
foreach($chars as $char) {
$cl = $fontDirectory.'/'.$char.'.png';
$charsImgs[] = imagecreatefrompng($cl);
@list($width) = getimagesize($cl) or exit;
$charsWidth[] = $width;
$imgWidth = $imgWidth+$width;
}
// Create and merge final image
$imgWidth = ($pos*2)+$imgWidth;
$img = imagecreate($imgWidth, height);
$bg = imagecolorallocate($img, 255, 255, 255);
foreach($charsImgs as $charsImg) {
$width = array_shift($charsWidth);
imagecopymerge($img, $charsImg, $pos, 0, 0, 0, $width, height, 100);
$pos = $pos+$width;
}
// Flush image
imagepng($img);
imagedestroy($img);
exit;
?>
Create a folder with the name of your font, bearing each character (in PNG format). The space image should be named "_.png", as you can't have spaces in some O/Ss file names. Modify config.php to fit your needs. Don't worry about paying me.PHP Code:<?php
# CONFIG
#Image height:
define("height", 50);
#Left and right margin:
$pos = '10';
#Font and its directory (more may be added):
$fonts['test'] = 'test';
$fonts['blah'] = 'blah';
# CONFIG END --
?>
Last edited by nets; 03-12-2006 at 08:43 PM.
kinda quit.
Thanks joshua.
I will pay you when I get my paypal account unlocked
Bump. About paying, I wrote a script a similar script a while ago, so there wasn't much coding to do (thanks for the offer though). I've added the script to my previous post.
Last edited by nets; 03-12-2006 at 08:46 PM.
kinda quit.
http://www.ffwbmarion.com/imagergd/t...p?message=test
To those not using PHP 5:Warning: Cannot modify header information - headers already sent by (output started at /home/ffwb/public_html/imagergd/configj.php:17) in /home/ffwb/public_html/imagergd/testj.php on line 4
Fatal error: Call to undefined function: str_split() in /home/ffwb/public_html/imagergd/testj.php on line 8
PHP Code:<?php
require ('config.php');
if(!function_exists('str_split')){
function str_split($string,$split_length=1){
$count = strlen($string);
if($split_length < 1){
return false;
} elseif($split_length > $count){
return array($string);
} else {
$num = (int)ceil($count/$split_length);
$ret = array();
for($i=0;$i<$num;$i++){
$ret[] = substr($string,$i*$split_length,$split_length);
}
return $ret;
}
}
}
// Check Message
if(preg_match("/^[a-zA-Z0-9 ]{0,30}$/", $_GET['message']) && !empty($_GET['message'])) {
$chars = str_split(str_replace(' ', '_', $_GET['message']));
} else {
$chars = str_split('Invalid_Message');
}
// Assign font variable
$fontDirectory = $fonts[$_GET['font']];
if($fontDirectory == '') $fontDirectory = 'test';
// Count size and create images
foreach($chars as $char) {
$cl = $fontDirectory.'/'.$char.'.png';
$charsImgs[] = imagecreatefrompng($cl);
@list($width) = getimagesize($cl) or exit;
$charsWidth[] = $width;
$imgWidth = $imgWidth+$width;
}
// Create and merge final image
$imgWidth = ($pos*2)+$imgWidth;
$img = imagecreate($imgWidth, height);
$bg = imagecolorallocate($img, 255, 255, 255);
foreach($charsImgs as $charsImg) {
$width = array_shift($charsWidth);
imagecopymerge($img, $charsImg, $pos, 0, 0, 0, $width, height, 100);
$pos = $pos+$width;
}
// Flush image
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
exit;
?>
Last edited by Dentafrice1; 03-12-2006 at 08:53 PM.
It's working fine now?
Last edited by nets; 03-12-2006 at 08:59 PM.
kinda quit.
http://www.ffwbmarion.com/imagergd/t...ge=a&font=blah
comes up with a broken imagePHP Code:<?php
require ('configj.php');
if(!function_exists('str_split')){
function str_split($string,$split_length=1){
$count = strlen($string);
if($split_length < 1){
return false;
} elseif($split_length > $count){
return array($string);
} else {
$num = (int)ceil($count/$split_length);
$ret = array();
for($i=0;$i<$num;$i++){
$ret[] = substr($string,$i*$split_length,$split_length);
}
return $ret;
}
}
}
// Check Message
if(preg_match("/^[a-zA-Z0-9 ]{0,30}$/", $_GET['message']) && !empty($_GET['message'])) {
$chars = str_split(str_replace(' ', '_', $_GET['message']));
} else {
$chars = str_split('Invalid_Message');
}
// Assign font variable
$fontDirectory = $fonts[$_GET['font']];
if($fontDirectory == '') $fontDirectory = 'test';
// Count size and create images
foreach($chars as $char) {
$cl = $fontDirectory.'/'.$char.'.gif';
$charsImgs[] = imagecreatefromgif($cl);
@list($width) = getimagesize($cl) or exit;
$charsWidth[] = $width;
$imgWidth = $imgWidth+$width;
}
// Create and merge final image
$imgWidth = ($pos*2)+$imgWidth;
$img = imagecreate($imgWidth, height);
$bg = imagecolorallocate($img, 255, 255, 255);
foreach($charsImgs as $charsImg) {
$width = array_shift($charsWidth);
imagecopymerge($img, $charsImg, $pos, 0, 0, 0, $width, height, 100);
$pos = $pos+$width;
}
// Flush image
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
exit;
?>![]()
Want to hide these adverts? Register an account for free!