Re: Transparent image
From: Michael Fuhr (mfuhr_at_fuhr.org)
Date: 11/29/03
- Next message: R. Rajesh Jeba Anbiah: "Re: Transparent image"
- Previous message: Chung Leong: "Re: objects... asp does... php doesn't"
- In reply to: AMcD: "Transparent image"
- Next in thread: AMcD: "Re: Transparent image"
- Reply: AMcD: "Re: Transparent image"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Nov 2003 22:14:00 -0700
"AMcD" <arnold.mcdonald@free.fr> writes:
> <?php
> Header('Content-type: image/png');
>
> $sz = "";
> $FileValue = 1000;
> $i = strlen($FileValue);
> for ( $j = 0; $j < 7-$i; $j++ )
> {
> $sz = $sz . "0";
> }
This isn't related to your problem, but are you familiar with the
sprintf() function? You're going to a lot of trouble to add leading
zeros when you could just do this:
$str = sprintf("%07d", $FileValue);
> $Img = imagecreate(56,13);
> $Gold = imagecolorallocate($Img,148,128,100);
> $Gray = imagecolorallocate($Img,32,32,32);
> ImageFilledRectangle($Img,0,0,55,12,$Gray);
> imagestring($Img,4,0,0,$sz.$FileValue,$Gold);
> imagepng($Img);
> ImageDestroy($Img);
> ?>
>
> OK. Calling this script I have a png picture back.
>
> Now I add imagecolortransparent($Img,$Gray); just before imagepng() and OK
> again, I have a transparent picture back. But now, if I add:
>
> $r = imagerotate($Img,90,0);
> imagepng($r);
>
> just after the imagecolortransparent() instruction seen above, I get a
> rotated picture, but not transparent. How to solve that? I've used a plenty
> of tricks, no one works.
Create the first image with imagecreatetruecolor() and then create
the rotated image like this:
$r = imagerotate($Img, 90, $Gray);
imagecolortransparent($r, $Gray);
I just tested this and the rotated image had a transparent background.
-- Michael Fuhr http://www.fuhr.org/~mfuhr/
- Next message: R. Rajesh Jeba Anbiah: "Re: Transparent image"
- Previous message: Chung Leong: "Re: objects... asp does... php doesn't"
- In reply to: AMcD: "Transparent image"
- Next in thread: AMcD: "Re: Transparent image"
- Reply: AMcD: "Re: Transparent image"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|