coolcommands.com - the search engine for unix sysadmins :: unix commands and scripts
Sunday May 27, 2012


 Home
 Search
 Advanced Search
 Category Search
 Affiliates
 Acknowledgements
 Cool Links

Username

Password

Remember me
Forgot your password?
Create an account

Who's Online
We have 23 guests online

Newest Member

beyondimagem

Hit Counter
9133552 Visitors

cool Statistics
coolcommands:1330
Categories:83
Total queries:595500
Members:16437





Category Search coolcommands.com
Select Category:


coolcommand

how to create an image with variable text on the fly with PHP
Description

To create an image on the fly using PHP, you need PHP compiled with the GD image library.

Here is the PHP code as an example to create a PNG image for a button which we will add dynamic text to. I call this button_on.php:

<?php
header("Content-type: image/png");
$string = $_GET['text'];
$im = imagecreatefrompng("button_on.png");
$black = imagecolorallocate($im, 0, 0, 0);
$px = (imagesx($im) - 7 * strlen($string)) / 2;
imagestring($im, 3, $px, 5, $string, $black);
imagepng($im);
imagedestroy($im);
?>


Notes:

1) You need a basic button image in PNG format which we use a base. In my case it is called button_on.png

2) Set the color of the text to whatever you want. In my case, I set it to black (notice color code 0,0,0)

3) To test, call your PHP like this: http://www.domain.com/button_on.php?text=SomeText or for multiple word buttons: http://www.domain.com/button_on.php?text=Some%20Text

4) You can include this in your web pages for dynamic images like this: <img src="button_on.php?text=Specification">
Example

http://www.domain.com/button_on.php?text=SomeText

Return to search results

Random coolcommands

coolcommand: how to select a database in Sybase
Example: isql -U sa password; use master; go
[show me the details]
coolcommand: how to mount a cd manually in AIX
Example: mount -V cdrfs -o ro /dev/cd0 /cdrom
[show me the details]
coolcommand: how to execute a task in SUMA in AIX 5L
Example: suma -x -w -a Action=Download 23
[show me the details]
coolcommand: how to alter the type of a field in a mysql database
Example: alter table tablename modify field1 tinyint not null;
[show me the details]

coolcommands.com - the search engine for UNIX sysadmins :: unix commands and scripts



FREE
myPMS

Password
Management
System

by

LVOware.com




Top 5 Submitters

lvo1152
audet37
kah00na32
Mariom24
lebjf00014

Top 5 Searches

Category Solaris49379
Category AIX46267
Category General UNIX43933
solaris22927
aix22116

Terms of Use
Privacy
Contact


 
coolcommands.com © 2012. All Right Reserved.
Programming by PRATTICO Consulting . Hosting by Apricusum