Coder Social home page Coder Social logo

Comments (8)

claviska avatar claviska commented on June 14, 2024

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.

maPer77 avatar maPer77 commented on June 14, 2024

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.

claviska avatar claviska commented on June 14, 2024

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.

maPer77 avatar maPer77 commented on June 14, 2024

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.

claviska avatar claviska commented on June 14, 2024

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.

maPer77 avatar maPer77 commented on June 14, 2024

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.

claviska avatar claviska commented on June 14, 2024

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.

maPer77 avatar maPer77 commented on June 14, 2024

thanks

from simpleimage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.