Page 1 of 1

How to get Image information...

Posted: 2017-01-02T17:13:45-07:00
by m990xd
Hello.
I'm a newbie and trying to use some get functions.
But some get functions return right values, some return nothing.

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <MagickWand/MagickWand.h>

void test_wand(void)
{
	MagickWand *mw = NULL;
	MagickBooleanType status;
	int width;
	char *outStr;
	
	MagickWandGenesis();
	mw = NewMagickWand();
	
	status = MagickReadImage(mw,"20170102_130111.jpg");
	if (status == MagickFalse) ThrowWandException(mw);
	
	outStr = (char *)MagickGetFormat(mw);
	if(outStr == NULL) {
		printf("Format is NULL\n");
		ThrowWandException(mw);
	}
	printf("Format: %s\n", outStr);
	
	outStr = (char *)MagickGetFilename((const)mw);
	if(outStr == NULL) {
		printf("filename is NULL\n");
		ThrowWandException(mw);
	}
	printf("filename: %s\n", outStr);

	printf("width=%d\n", MagickGetImageWidth(mw));
	
	if(mw) mw = DestroyMagickWand(mw);
	MagickWandTerminus();
}
Output of execution is following..........
Format:
filename:
width=4128

MagickGetFormat and MagickGetFilename return something strange and not null. MagickGetImageWidth returns a right thing.
Please let me know what to do...

Thanks in advance...

Re: How to get Image information...

Posted: 2017-01-02T18:02:16-07:00
by snibgo
You haven't set a filename or format for the wand. But you have for the image in the wand, so you need MagickGetImageFormat() etc.

Re: How to get Image information...

Posted: 2017-01-02T19:41:35-07:00
by m990xd
I solved my problem.
As you mentioned, I used magickGetImageFormat() and magickGetImageFilename() instead of magickGetFormat() and magickGetFilename(), I was successful.
I understood the difference between wand and image.

snibgo, thank you a lot. ^^