Page 1 of 1

Programmatically finding file support.

Posted: 2010-08-20T09:33:41-07:00
by boffo
Hello everyone.

Is there some way to interrogate MagickWand (in c/c++) to find out which file types or file extensions are supported?

For the life of me, I'm not seeing that in the API.

Re: Programmatically finding file support.

Posted: 2010-08-20T09:39:48-07:00
by magick
You can call MagickSetImageFormat() and if it returns MagickFalse, the image format is not recognized or not supported. You can also call the MagickCore API method GetMagickInfo(). If it returns a non-null result, the image format is recognized and supported by ImageMagick.

Re: Programmatically finding file support.

Posted: 2010-08-30T15:44:16-07:00
by boffo
Thanks for the response.

So you are saying that the only way I can get a complete set of file formats is to call 'MagickSetImageFormat' for every 2-4 letter combination of letters and numerals? There isn't any way to get back a simple list of what's supported?

regards.

Re: Programmatically finding file support.

Posted: 2010-08-30T16:11:46-07:00
by magick
You can get a list of all supported image formats with a MagickCore API call:
  • p = GetMagickInfo("*",exception);

Re: Programmatically finding file support.

Posted: 2010-08-30T17:02:51-07:00
by boffo
Aha...thanks.

Re: Programmatically finding file support.

Posted: 2010-08-30T17:48:03-07:00
by boffo
Ah well...bummer.

It works fine, according to Visual Studio it's loading a whole slew of *.dll's (things like IM_MOD_RL_tga_.dll), and then it gets up to
'IM_MOD_RL_xtrn_.dll'', and then blammo:

First-chance exception at 0x048decd5 in test.exe: 0xC0000005: Access violation reading location 0x00000014.
Unhandled exception at 0x048decd5 in test.exe: 0xC0000005: Access violation reading location 0x00000014.

No biggie, I'll just have to have a list of file types in my own application. It's less elegant but should work fine.

Re: Programmatically finding file support.

Posted: 2010-08-30T18:45:51-07:00
by el_supremo
FYI: This C function works fine on my Win XP system using IM 6.6.3-9
It writes the list of 208 formats into the file "formats.txt".

Pete

Code: Select all

#include <windows.h>
#include <magick/MagickCore.h>
void test_wand(void)
{
	ExceptionInfo *exception;
	const MagickInfo **mi_ptr = NULL;
	size_t num_ptr; 
	size_t i;
	FILE *fdo = NULL;

	MagickCoreGenesis((char *) NULL,MagickFalse);
	// Get and Initialize an exception info
	exception = AcquireExceptionInfo();
	GetExceptionInfo(exception);

	mi_ptr = GetMagickInfoList("*",&num_ptr,exception);
	if(mi_ptr == NULL) {
		MessageBox(NULL,"NULL list returned","",MB_OK);
	} else {
		fdo = fopen("formats.txt","w");
		for(i=0;i<num_ptr;i++) {
			fprintf(fdo,"%s\n",mi_ptr[i]->name);
		}
		fclose(fdo);
	}

	DestroyExceptionInfo(exception);
	MagickCoreTerminus();
}

Re: Programmatically finding file support.

Posted: 2010-08-30T22:53:10-07:00
by boffo
Many thanks, that's exactly what I needed to know. It works now.