Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Convertors


  • Please log in to reply
4 replies to this topic

#1 yowza

yowza

  • Members
  • 110 posts
  • OFFLINE
  •  
  • Local time:11:19 PM

Posted 13 April 2005 - 06:27 PM

Hey there is a php code where u can type wat u want in toa box with a few options like how big it is and so on and it then makes the word only in images using a special font like only images does any one know the code? i rly need it examples r on http://www.gihabbo.co.uk/index.php?gi=habtx

BC AdBot (Login to Remove)

 


#2 jgweed

jgweed

  • Staff Emeritus
  • 28,473 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Chicago, Il.
  • Local time:11:19 PM

Posted 13 April 2005 - 11:43 PM

There are many sites that provide php codes; here is one:

http://codewalkers.com/code.php

Regards,
John
Whereof one cannot speak, thereof one should be silent.

#3 yowza

yowza
  • Topic Starter

  • Members
  • 110 posts
  • OFFLINE
  •  
  • Local time:11:19 PM

Posted 14 April 2005 - 04:34 AM

hey thx for replying i know there r loads of them but i never know which is rhe right section which section wil it be in ?

#4 ColdinCbus

ColdinCbus

  • Members
  • 312 posts
  • OFFLINE
  •  
  • Local time:12:19 AM

Posted 14 April 2005 - 07:58 AM

That is PHP image handleing http://us4.php.net/image/
The below will pretty much do what you want, you will need to build an interface to pass the params to the script.
params:
$text  >  the string you want to write
$format  >  output format "jpeg" or "png"
$quality  >  jpeg quality, from 1 to 100
$font  >  font path and file
$size  >  font size (px)
$angle  >  angle of text in degrees
$r  >  font color: red part
$g  >  font color: green part
$b  >  font color: blue part
$bgr  >  background color: red part
$bgg  >  bg color: green part
$bgb  >  bg color: blue part
$margin  >  a margin between text and border of pic

code:
<?
if ($text != '')
{
  list(,,$w) = imagettfbbox($size, 0, $font, $text);
  $lines = count(explode("\n", $text));

  // get image size (not exactly)
  $angle_rad = $angle / 180 * pi();
  $h = 2 * $size * $lines;
  $x = round($h * abs(sin($angle_rad)) + $w * abs(cos($angle_rad))) + $size;
  $y = round($h * abs(cos($angle_rad)) + $w * abs(sin($angle_rad))) + $size;

  // get start point for text
  $run_y = - $lines * $size + 1.5 * $size;
  $s_x = round($x / 2 - ($w / 2) * cos($angle_rad) + $run_y * sin($angle_rad));
  $s_y = round($y / 2 + ($w / 2) * sin($angle_rad) + $run_y * cos($angle_rad));

  // create image
  $im = imagecreatetruecolor($x, $y);
  @imageantialias($im, true);
  $bg  = imagecolorallocate ($im, $bgr, $bgg, $bgb);
  $tx  = imagecolorallocate ($im, $r, $g, $b);
  #imagecolortransparent ($im, $bg);
  imagefill($im, 0, 0, $bg);

  // put text
  imagettftext ($im, $size, $angle, $s_x, $s_y, $tx, $font, $text);

  // minimize borders
  // left
  for ($x = 0; $x < imagesx($im); $x++)
  {
   for ($y = 0; $y < imagesy($im); $y++)
   {
     if (imagecolorat($im, $x, $y) != $bg) break(2);
   }
  }
  $left = $x;
  // right
  for ($x = imagesx($im) - 1; $x >= 0; $x--)
  {
   for ($y = 0; $y < imagesy($im); $y++)
   {
     if (imagecolorat($im, $x, $y) != $bg) break(2);
   }
  }
  $right = $x;
  // top
  for ($y = 0; $y < imagesy($im); $y++)
  {
   for ($x = 0; $x < imagesx($im); $x++)
   {
     if (imagecolorat($im, $x, $y) != $bg) break(2);
   }
  }
  $top = $y;
  // bottom
  for ($y = imagesy($im) - 1; $y >= 0; $y--)
  {
   for ($x = 0; $x < imagesx($im); $x++)
   {
     if (imagecolorat($im, $x, $y) != $bg) break(2);
   }
  }
  $bottom = $y;

  // add margin
  $cut = imagecreatetruecolor($right - $left + 1 + $margin * 2, $bottom - $top + 1 + $margin * 2);
  $bg_ = imagecolorallocate ($cut, $bgr, $bgg, $bgb);
  imagefill($cut, 0, 0, $bg_);
  imagecopy ($cut, $im, $margin, $margin, $left, $top, $right - $left + 1, $bottom - $top + 1);

  // output
  if ($format == 'jpeg')
  {
   header("Content-type:image/jpeg");
   imagejpeg($cut,false,$quality);
  }
  elseif ($format == 'png')
  {
   header("Content-type:image/png");
   imagepng($cut);
  }
}
?>


#5 yowza

yowza
  • Topic Starter

  • Members
  • 110 posts
  • OFFLINE
  •  
  • Local time:11:19 PM

Posted 14 April 2005 - 03:14 PM

hey coldin thanks for replying do u think u could maybe help me though beacuse im not that advanced in php and stuff could u help me set one up ? my serveer i host from does enable php




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users