How to get Image information...

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
m990xd
Posts: 2
Joined: 2017-01-02T16:59:53-07:00
Authentication code: 1151

How to get Image information...

Post 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...
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to get Image information...

Post 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.
snibgo's IM pages: im.snibgo.com
m990xd
Posts: 2
Joined: 2017-01-02T16:59:53-07:00
Authentication code: 1151

Re: How to get Image information...

Post 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. ^^
Post Reply