Re: [PHP] Change gif image with php

2002-02-16 Thread Adrian Murphy

button.php
?php
  Header(Content-type: image/gif);

 $string=str_replace(%20,  , $string);
 $theimage = images/ . $button ..gif;
$im = imageCreateFromgif($theimage);
$white = ImageColorAllocate($im, 255, 255, 255);


$font = /fonts/VERDANAB.TTF;
 $box = imagettfbbox ( 12, 0, $font, $string);


 $th=$box[7]-$box[3];
 $th= $th + 2;
 $py = (imagesy($im) -$th)/2;

 $px  = (imagesx($im) -($box[2]-$box[0]))/2;

 $size = 12;



 ImageTTFText ($im, $size, 0, $px, $py, $white,$font,$string);

Imagegif($im);
ImageDestroy($im);
?

fot this to work you need to upload VERDANAB.TTF to a folder called  'fonts'
and you call the image like this:
to draw 'hello' on a button called 'mybutton.gif' stored in 'images' folder
img src=button.php?string=hellobutton=mybutton

- Original Message -
From: Rodrigo Peres [EMAIL PROTECTED]
To: PHP [EMAIL PROTECTED]
Sent: Saturday, February 16, 2002 7:49 PM
Subject: [PHP] Change gif image with php


 Hi list

 I have some buttons made in photoshop in .gif format. This buttons have
 round corner, feather, multiple colors etc. There's a way to open it with
 php and write some text to it. I know that is possible to create images,
but
 what about to change them??? I need to do this because the text that will
 fill the buttons come from mysql and change everyday.

 Thank's in advance


 Rodrigo


 ps: If someone want to see the button I'm talking look in
 http://www.celebnet.com.br/home.php under the AS ++.


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Change gif image with php

2002-02-16 Thread Andrew Brampton

ya its completly possible..
I've never done it, but I'm sure I read how to over at phpbuilder.com

Andrew
- Original Message -
From: Rodrigo Peres [EMAIL PROTECTED]
To: PHP [EMAIL PROTECTED]
Sent: Saturday, February 16, 2002 7:49 PM
Subject: [PHP] Change gif image with php


 Hi list

 I have some buttons made in photoshop in .gif format. This buttons have
 round corner, feather, multiple colors etc. There's a way to open it with
 php and write some text to it. I know that is possible to create images,
but
 what about to change them??? I need to do this because the text that will
 fill the buttons come from mysql and change everyday.

 Thank's in advance


 Rodrigo


 ps: If someone want to see the button I'm talking look in
 http://www.celebnet.com.br/home.php under the AS ++.


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Change gif image with php

2002-02-16 Thread hugh danaher

Rodrigo,
I've been struggling with this for some time, so here goes:

The php4 builds do not support .gif files, you'll need to change your files
to .jpg or .png format, or use php3 (I can't change to php3).

I use imagecreate() func. before imagecreatefromjpeg() func. because if I
didn't do this, the added text would be gray regardless of the desired
color.

The mysql portion is solid and yields the desired results.

However, I'm having trouble with something related to the
imagecreatefromjpeg() func., I get a server error (500) on some images
regardless of their size.  This is the only error produced by the func. and
it is maddening.  From experimentation, I believe that there's something
wrong with the .jpg files, the .jpg file upload, or the phase of the moon.

Good luck,
Hugh




?php
header(content-type: image/jpg);

$font=fonts/arial.ttf;
$font2=fonts/wingding.ttf;

$im_size = GetImageSize($image_file);
$imWidth = $im_size[0];
$imHeight = $im_size[1];

$image=ImageCreate($imWidth,$imHeight);

$black=imagecolorallocate($image,0,0,0);
$white=imagecolorallocate($image,255,255,255);
$red=imagecolorallocate($image,255,100,100);
$orange=imagecolorallocate($image,255,200,0);
$yellow=imagecolorallocate($image,233,233,0);
$green=imagecolorallocate($image,80,255,80);
$lt_blue=imagecolorallocate($image,180,180,255);
$blue=imagecolorallocate($image,120,120,255);
$dk_blue=imagecolorallocate($image,0,0,200);
$purple=imagecolorallocate($image,200,100,200);
$brown=imagecolorallocate($image,190,160,150);

$image2=imagecreatefromjpeg($image_file);


imagecopy ($image, $image2, 0, 0, 0, 0, $imWidth, $imHeight);

 $db=data_base_name;
 $pass=password;
 $link=mysql_connect(localhost,,$pass);
 if (! $link) die(Can't log in at this time);
 mysql_select_db($db,$link) or die (Can't log in at this time);
 $query=mysql query ;
 $results=mysql_query($query);
 if (!$results) die(mysql_error());
 mysql_close($link);

while ($landmark=mysql_fetch_array($results))
 {
 $coordinate_x=$landmark['x'];
 $coordinate_y=$landmark['y'];
 $plant=$landmark['plant'];
 if ($plant==flowering) $var_color=$red;
 if ($plant==conifer) $var_color=$orange;
 if ($plant==palm) $var_color=$yellow;
 if ($plant==other) $var_color=$lt_blue;

 imagettftext($image,  5, 0,$coordinate_x-3, $coordinate_y-4, $black,
$font2, l);
 imagettftext($image, 19, 0,$coordinate_x-7, $coordinate_y+4, $black,
$font2, l);
 imagettftext($image, 17, 0,$coordinate_x-6, $coordinate_y+2,
$black,$font2,l);
 imagettftext($image, 17, 0,$coordinate_x-6, $coordinate_y+2, $var_color,
$font2, l);
 imagettftext($image,  5, 0,$coordinate_x-3, $coordinate_y-4, $white,
$font2, l);
 }

imagejpeg($image,./new/$image_file,100);

ImageDestroy($image);
ImageDestroy($image2);

header(location: finished.php);
?


- Original Message -
From: Rodrigo Peres [EMAIL PROTECTED]
To: PHP [EMAIL PROTECTED]
Sent: Saturday, February 16, 2002 11:49 AM
Subject: [PHP] Change gif image with php


 Hi list

 I have some buttons made in photoshop in .gif format. This buttons have
 round corner, feather, multiple colors etc. There's a way to open it with
 php and write some text to it. I know that is possible to create images,
but
 what about to change them??? I need to do this because the text that will
 fill the buttons come from mysql and change everyday.

 Thank's in advance


 Rodrigo


 ps: If someone want to see the button I'm talking look in
 http://www.celebnet.com.br/home.php under the AS ++.


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Change gif image with php

2002-02-16 Thread Rasmus Lerdorf

 Rodrigo,
 I've been struggling with this for some time, so here goes:
 
 The php4 builds do not support .gif files, you'll need to change your files
 to .jpg or .png format, or use php3 (I can't change to php3).

This is not true.  GIF support depends solely on the version of the GD 
library PHP is linked against.  GIF support was not removed from PHP.  It 
was removed from later versions of the GD library.  Simply grab an older 
version of GD which has GIF support and link PHP against that.

-Rasmus


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php