Comments (8)
I can't replicate this. In addition, this page of the PHP manual has examples with imagefilledrectangle
and imagefilledellipse
, the latter of which shows an example with transparency. That would imply that both these functions do support it, so maybe your issue is with something else?
The first comment on the imagefill
page also says that you can't fill an image with transparency. I tried it just to see, but it didn't work for me. I would be reluctant to use this method anyways, since it would be much more memory intensive to perform a flood fill than to fill just a rectangle.
Has anyone else run into a similar issue?
from simpleimage.
hello claviska
The way I found to get a new transparent image. I created a transparent png small 10x10px, then open this PNG and then resize to the size I want.
$transparent = 'Transparent.png';
$img = new abeautifulsite\SimpleImage($transparent);
$img->resize(300, 100);
You can create a transparent image? I was trying with this code:
$img = new abeautifulsite\SimpleImage(null, 200, 100, array(0,0,0,127) );
Did I was not doing correctly?
tks
from simpleimage.
Ah, I didn't realize you were starting with a transparent image. I tried creating a new one from scratch like this:
$img = new abeautifulsite\SimpleImage(null, 200, 100, array(0,0,0,127) );
In theory, it should be black with 50% transparency, but it was black and opaque as you stated. Alpha-transparency can be tricky with GD, so it could be something we're doing wrongโor it could be that GD simply doesn't support it with this function.
Unfortunately, alpha-transparency in GD isn't my niche, so it will take some experimenting unless someone else can figure it out first.
from simpleimage.
I started with a transparent image now, to solve the problem, before i was trying to:
$img = new abeautifulsite\SimpleImage(null, 200, 100, array(0,0,0,127) );
In theory it should work, but this did not work for me.
Also to do with the base64:
$transparent = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABBJREFUeNpi+P//PwNAgAEACPwC/tuiTRYAAAAASUVORK5CYII=';
$img = new abeautifulsite\SimpleImage($transparent);
$img->resize(300, 100);
from simpleimage.
That might be a helpful workaround if we need to start with a transparent canvas. I'd still like to find out why transparency doesn't work as expected, though.
On Aug 21, 2013, at 10:03 PM, ciganox [email protected] wrote:
I started with a transparent image now, to solve the problem, before i was trying to:
$img = new abeautifulsite\SimpleImage(null, 200, 100, array(0,0,0,127) );
In theory it should work, but this did not work for me.
Also to do with the base64:
$transparent = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABBJREFUeNpi+P//PwNAgAEACPwC/tuiTRYAAAAASUVORK5CYII=';
$img = new abeautifulsite\SimpleImage($transparent);
$img->resize(300, 100);โ
Reply to this email directly or view it on GitHub.
from simpleimage.
Maybe it's a problem of the GD library, but at least managed to find a solution, and there is a tip for those who need it.
PS. sorry if I write not right, because I use google translator
from simpleimage.
This will work now:
$img = new abeautifulsite\SimpleImage(null, 500, 500, array(0,0,0,64) );
$img->save('50-percent-transparent.png');
Just remember that the alpha value must be 0-127, zero being opaque and 127 being transparent. I was getting this confused with the 256 levels in each color channel.
from simpleimage.
thanks
from simpleimage.
Related Issues (20)
- A feature to fit image in a fixed canvas size with blur background of original image. HOT 2
- Auto fit in square and use source image as background.
- resize function does not check size values HOT 2
- Can not add a text on image HOT 2
- PNG to JPG is possible to change transparent background color? HOT 2
- Background color for text HOT 7
- How to different font file & size, but in an equal position with center align HOT 3
- PHP 8.2: Deprecation warning "Creation of dynamic property"
- Implicit conversion from float 50.800000000000004 to int loses precision HOT 2
- Imagick magick support HOT 1
- Bump `thephpleague/color-extractor` to 0.4 in composer.json HOT 1
- Nothing working HOT 1
- Implicit conversion from float to int loses precision HOT 3
- QR Code HOT 1
- getExif(): Return value must be of type ?array, bool returned HOT 1
- Images not destroyed? HOT 1
- Set fixed size for overlay image
- Request: Combine two pictures
- Implicit conversion from float 56.25 to int loses precision HOT 1
- PHP E_WARNING when imagecreatefromstring() is used
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simpleimage.