Tech Support Guy banner
Status
Not open for further replies.

Text to Pic

733 views 8 replies 3 participants last post by  ehymel 
#1 ·
Hi,
I asked something along these lines a while ago - but I think I complicated it a little, and never really got an answer..

what I want to know is how is this kind of thing done?

Link
 
#4 ·
the question was, how does the taking text from an image and embedding it into an image work...

Yes my other topic in regards to access that you've linked to there is related.. heres what I'm wanting to do:

I work in a retail computer store, we used to have a website that was made specifically for us to generate signs for the store - ie price & spec sheets for laptops - which are saved as jpgs and set as the demo computers wallpaper.
The signs were created by the user filling out the various fields in a form (php) which were then embedded into the image for us to save.

Problem is the website that we were using has gone belly up, and the person that created it is no longer contactable, so I've half stuck my hand up/been asked to see what I can come up with. The system would need to be centralised so it can be accessed from several locations.. the access database that I started on is linked back to a MySQL database on a server..
 
#6 ·
Im not wanting to extract it from an image, Im wanting to insert it..

While we could use photoshop to type in the text to make each sign, its not ideal because a) its slow to do b) the data isnt being kept in a central location.
 
#9 ·
Since you are using php, there are 2 ways to do this.

1. Server side with a php script using the ImageMagick package. I've used this script, which I call button.php, for a few years to generate buttons on the fly (forgot where I go this script, apologies to the creator):
PHP:
<?php
   Header("Content-type: image/gif");
   $text = $_GET['text'];
   $font = "arial.ttf";
   $s=11;
   if(!isset($s)) $s=11;
   $size = imagettfbbox($s,0,$font,$text);
   $dx = abs($size[2]-$size[0]);
   $dy = abs($size[5]-$size[3]);
   $xpad=10;
   $ypad=10;
   $im = imagecreate($dx+$xpad,$dy+$ypad);
   $blue = ImageColorAllocate($im, 0xe6,0xe7,0xbf);
   $black = ImageColorAllocate($im, 0,0,0);
   $white = ImageColorAllocate($im, 255,255,255);
   ImageRectangle($im,0,0,$dx+$xpad-1,$dy+$ypad-1,$black);
   ImageRectangle($im,0,0,$dx+$xpad,$dy+$ypad,$white);
   ImageTTFText($im, $s, 0, (int)($xpad/2), $dy+(int)($ypad/2)-1, $black, $font, $text);
   ImageGif($im);
   ImageDestroy($im);
?>
You have to tell the script where to find your font file (here, arial.ttf is in the same directory as my button.php script. You also have to have the ImageMagick package installed on your server.
This is called from html script using something like:
Code:
<img src="/images/button.php?text=Save updated info">
2. Client side using css and javascript. I use jquery ui button widget (http://jqueryui.com/demos/button/). *Extremely* simple to use, easily customizable, cross-browser compatible, but depends on client-side javascript.
 
Status
Not open for further replies.
You have insufficient privileges to reply here.
Top