Got things to work with c# on win 7 64 bit
Posted: 2010-11-22T15:24:22-07:00
There seems to be a lack of examples for calling the imagemagickobject library from c#.
So hopefully this will help others.
I am using VS 2008 on windows 7 64 bit.
I had the 32 bit of IM installed, and the dll referenced, but was getting the error where it could not make the object at runtime.
Seems that is well understood as I was calling a 32 bit dll from a 64 bit prog.
I then reomoved IM and installed the 64 bit version and referenced the new dll.
I think the install registered the new imagemagickobject dll, but I did it anyway and even checked the registry to see that it worked.
Of course, if you are on 32 bit, just use 32 bit install...
Then it took me a while to get the identify command to work. The initial problems I had with 32 bit dll confused me as to if I was creating the right object.
Turns out the examples out there were right, use ImageMagickObject.MagickImage.
Then had thought the filename went first in the params list, but it goes last. I should have known on that.
Anyway, if you reference the dll, and use this code, you should get a valid return:
ImageMagickObject.MagickImage img = new ImageMagickObject.MagickImage();
object[] args = new object[] { "-format", "%r", origName };
object result = img.Identify(ref args);
so that is working so far. Not that complicated once I was done, but the other examples never mention 64 bit issues or show actual c# code.
thanks
So hopefully this will help others.
I am using VS 2008 on windows 7 64 bit.
I had the 32 bit of IM installed, and the dll referenced, but was getting the error where it could not make the object at runtime.
Seems that is well understood as I was calling a 32 bit dll from a 64 bit prog.
I then reomoved IM and installed the 64 bit version and referenced the new dll.
I think the install registered the new imagemagickobject dll, but I did it anyway and even checked the registry to see that it worked.
Of course, if you are on 32 bit, just use 32 bit install...
Then it took me a while to get the identify command to work. The initial problems I had with 32 bit dll confused me as to if I was creating the right object.
Turns out the examples out there were right, use ImageMagickObject.MagickImage.
Then had thought the filename went first in the params list, but it goes last. I should have known on that.
Anyway, if you reference the dll, and use this code, you should get a valid return:
ImageMagickObject.MagickImage img = new ImageMagickObject.MagickImage();
object[] args = new object[] { "-format", "%r", origName };
object result = img.Identify(ref args);
so that is working so far. Not that complicated once I was done, but the other examples never mention 64 bit issues or show actual c# code.
thanks