Jump to content

Image Functions


nic

Recommended Posts

I'm having a weird problem with the Php GD lib image function. This code works perfectly:

 

header("Content-type: image/png");

 

$im = imagecreatetruecolor(150, 20);

 

$string = strtoupper($_GET['s']) ;

$white = imagecolorallocate($im, 255, 255, 255);

$color = imagecolorallocate($im, 186, 176, 164);

$font = '../../fonts/Optima.suit';

 

imagefilledrectangle($im, 0, 0, 150, 20, $white);

imagettftext($im, 9, 0, 0, 20, $color, $font, $string);

 

imagepng($im);

imagedestroy($im);

 

 

but this gives me a broken link:

 

header("Content-type: image/png");

$string = $_GET['text'];

$im     = imagecreatefrompng("button.png");

$orange = imagecolorallocate($im, 220, 210, 60);

$px     = (imagesx($im) - 7.5 * strlen($string)) / 2;

imagestring($im, 3, $px, 9, $string, $orange);

imagepng($im);

imagedestroy($im);

 

 

The fact that the first example works makes me think required libraries are install fine, but the second example is copied straight out of the Php manual, which can't be wrong.... I'm so confused.

 

 

Any help here would be appreciated.

 

Thanks

 

nicholas

Link to comment
https://forums.phpfreaks.com/topic/46742-image-functions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.