How to create transparent image

MagickWand for PHP is an object-oriented PHP interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning MagickWand for PHP.
Post Reply
vav

How to create transparent image

Post by vav »

Hi,
I'm porting my scripts from command line to MagickWand API and I'd like to know how to create simple transparent image:

Code: Select all

convert -size 100x100 xc:none empty.png
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Post by el_supremo »

I have a C function, which uses MagickWand to produce a plain transparent PNG. This should give you the essence of what is required for a PHP script.

Pete

Code: Select all

/*	
	Make a plain transparent image
*/
#include <windows.h>
#include <wand/magick_wand.h>

void test_wand(void)
{
	MagickWand *magick_wand = NULL;

	PixelWand *p_wand = NULL;


	MagickWandGenesis();

	magick_wand = NewMagickWand();
	MagickSetImageMatte(magick_wand,MagickTrue);

	p_wand = NewPixelWand();
	PixelSetColor(p_wand,"none");

	MagickNewImage(magick_wand,100,100,p_wand);

	MagickWriteImage(magick_wand,"empty.png");

	/* Clean up */
	if(magick_wand)magick_wand = DestroyMagickWand(magick_wand);
	if(p_wand)p_wand = DestroyPixelWand(p_wand);
	MagickWandTerminus();
}
Post Reply