Documentation

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
jcasique

Documentation

Post by jcasique »

Hi everyone, I want to create a C program on AIX system to read image from a database in TIFF format and then resize, convert to JPG and finally write in file, I think i can use MagickWand to do it, but i don't have enough documentation, does anybody help with that.

Thank
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Documentation

Post by el_supremo »

Here's a C function which should get you started.
It reads in a TIFF, determines its dimensions, cuts them in half and resizes the image.
The image is then written as a high-quality JPG.

Code: Select all

/*
	Read a TIFF, cut its dimension in half using a Lanczos filter,
	set the image compression quality to 95 and write the result as
	a JPG

*/
#include <windows.h>
#include <wand/magick_wand.h>

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

	int width,height;

	MagickWandGenesis();

	m_wand = NewMagickWand();
	// Read the image
	MagickReadImage(m_wand,"input.tiff");
	
	// Get the image's width and height
	width = MagickGetImageWidth(m_wand);
	height = MagickGetImageHeight(m_wand);
	
	// Cut them in half but make sure they don't underflow
	if((width /= 2) < 1)width = 1;
	if((height /= 2) < 1)height = 1;

	// Resize the image
	// The filter is one of:
	//%    Bessel   Blackman   Box
	//%    Catrom   Cubic      Gaussian
	//%    Hanning  Hermite    Lanczos
	//%    Mitchell Point      Quandratic
	//%    Sinc     Triangle
	// The blur factor is a "double", where > 1 is blurry, < 1 is sharp
	MagickResizeImage(m_wand,width,height,LanczosFilter,0.5);

	// Set the compression quality to 95 (high quality = low compression)
	MagickSetImageCompressionQuality(m_wand,95);
	/* Write the new image */
	MagickWriteImage(m_wand,"output.jpg");

	/* Clean up */
	if(m_wand)m_wand = DestroyMagickWand(m_wand);

	MagickWandTerminus();
}
Pete
jcasique

Re: Documentation

Post by jcasique »

Hi, I test the example you post me, but I got this error during the compilation

"/usr/local/include/ImageMagick/magick/quantum.h", line 101.1: 1506-277 (S) Syntax error: possible missing ';' or ','?
"/usr/local/include/ImageMagick/magick/quantum.h", line 100.8: 1506-485 (S) Parameter declaration list is incompatible with declarator for inline.
"/usr/local/include/ImageMagick/magick/quantum.h", line 130.28: 1506-045 (S) Undeclared identifier quantum.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Documentation

Post by el_supremo »

I don't know what could cause that error.
I've just copied the code from my previous message, pasted it back into a C program, and recompiled it with IM V6.4.1 (Q8 DLL version on Windows) and it compiles without error.

Pete
Post Reply