Page 1 of 1

How to create transparent image

Posted: 2006-11-29T11:51:57-07:00
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

Posted: 2006-11-29T12:29:42-07:00
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();
}