php GD create a transparent png image

Set imagealphablending($image,true); on each new layer. Try this: <?php $image = imagecreatetruecolor(485, 500); imagealphablending($image, false); $col=imagecolorallocatealpha($image,255,255,255,127); imagefilledrectangle($image,0,0,485, 500,$col); imagealphablending($image,true); /* add door glass */ $img_doorGlass = imagecreatefrompng(“glass/$doorStyle/$doorGlass.png”); imagecopyresampled($image, $img_doorGlass, 106, 15, 0, 0, 185, 450, 185, 450); imagealphablending($image,true); /* add door */ $img_doorStyle = imagecreatefrompng(“door/$doorStyle/$doorStyle”.”_”.”$doorColor.png”); imagecopyresampled($image, $img_doorStyle, 106, 15, 0, 0, 185, 450, 185, 450); … Read more

Reasons for why a WinForms label does not want to be transparent?

Add a new class to your project and post the code shown below. Build. Drop the new control from the top of the toolbox onto your form. using System; using System.Windows.Forms; public class TransparentLabel : Label { public TransparentLabel() { this.SetStyle(ControlStyles.Opaque, true); this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false); } protected override CreateParams CreateParams { get { CreateParams parms = … Read more

How to make a transparent JFrame but keep everything else the same?

Basically, you need to make a transparent window and a translucent content pane. This will mean anything added to the content pane will continue to be rendered without additional alphering… public class TranscluentWindow { public static void main(String[] args) { new TranscluentWindow(); } public TranscluentWindow() { EventQueue.invokeLater(new Runnable() { @Override public void run() { try … Read more

PNG Transparency with PHP

I have had success doing it like this in the past: $thumb = imagecreatetruecolor($newwidth, $newheight); imagealphablending($thumb, false); imagesavealpha($thumb, true); $source = imagecreatefrompng($fileName); imagealphablending($source, true); imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); imagepng($thumb,$newFilename); I found the output image quality much better using imagecopyresampled() than imagecopyresized()

How to export plots from matplotlib with transparent background?

Use the matplotlib savefig function with the keyword argument transparent=True to save the image as a png file. In [30]: x = np.linspace(0,6,31) In [31]: y = np.exp(-0.5*x) * np.sin(x) In [32]: plot(x, y, ‘bo-‘) Out[32]: [<matplotlib.lines.Line2D at 0x3f29750>] In [33]: savefig(‘demo.png’, transparent=True) Result: Of course, that plot doesn’t demonstrate the transparency. Here’s a screenshot … Read more