Getting Started

Aug 25, 2009 at 9:46 AM

Hi there

Is there any setup needed in order to get started? Or can you just reference the relevant ImageMagickNET.dll from your C# project?

 

Regards,

Fredrik

Aug 31, 2009 at 10:16 AM

To answer that, I would say (being a beginner with this project also): probably yes.

Anyway, what's still missing is some documentation, explaining the .NET API provided in the assembly. Is there anything? Only the syntax of the classes and methods is not sufficient to work with it.

Thanks a log, anyway.

-Blueteeth

Dec 15, 2009 at 2:26 PM

Hey

I download the project and add the dll as a reference to my C# console app project. But when I try to run the program (F5) Im getting a error message.

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or ass
embly 'ImageMagickNET.dll' or one of its dependencies. The specified module coul
d not be found.
at TestApp.Program.Main(String[] args)


 I have installed C++ project templates when I install Visual Studio, so I think I have install the C++ runtime library. Any ideas?

Jan 5, 2010 at 11:30 PM
Edited Jan 6, 2010 at 12:08 AM

Well, I'm glad to see this product has some life.  I found the original work at (http://www.codeproject.com/KB/dotnet/ImageMagick_in_VBNET.aspx) and was able to create a working installation.  It has been a number of months so I cannot recall the specifics.  I think the exception is a result of not have the core DLL's in your project directory.  The setup details are at the code product site.

as far as documentation goes, it's all on the main Image Magick page once you have created an imagelist object you just set propeties/call methods simialr to the command line tool.

like this:

'Set the image quality
image.Quality(100)

'trim the image of white space
image.Trim()

'Save the modified image
imageList.WriteImages(strFileName,True)

'************** resize an image ************************
'get the current row & column values
cols = image.Columns()
'creat a new geometry object
Dim
NewSize As New ImageMagickNET.Geometry(CInt(dblNewWidth), rows, 0, 0, False, False)

rows = image.Rows()

'adjust the columns by a percentage
dblNewWidth = cols * dblPcnt 

 

'do the scale
image.Scale(NewSize)

 

Jul 27, 2011 at 1:11 AM

Can the developer of this library please list the requirements to use the DLL? The DLL in it's current form is throwing a FileNotFoundException when it is used. ImageMagick is a great tool for image manipulation and it's a shame we can't use it in .NET projects because of a lack of documentation.

Kento above was kind enough to point us to the original work but he/she was a little vague on where to find the setup details. If anyone knows how to use the DLL you get from the Codeplex project please let me know.

Thanks

Jul 27, 2011 at 3:54 PM

pseudoname,

I think your exception is due to the fact that your Image Magick DLL's are not in the same directory as your application.  The will need to be copied to each configuration (..\bin\debug, ..\bin\release, etc.).

From the original CodePlex article:

Notes on the CORE_RL*.DLLs

When running your application, make sure that the correct pixel quantization version Q8/Q16 of the CORE_RL*.DLLs, msvcp71.dll, msvcr71.dll and all other non-IM_MOD_RL*.DLLs reside on the same folder as your application. This is to ensure that your application loads the DLLs directly from its current path, instead of loading it from the ImageMagick folder.

Why do we do this? You may ask. This is because if you have both the Q8 and the Q16 installations of ImageMagick set up on your machine, Windows does not automatically know which CORE_RL*.DLLs to look for. It only looks for the DLLs, we believe, first in the current application directory, and then in the order of the folders specified in the PATH environment variable. Thus, if you have both Q8 and Q16 set up on your machine, then Windows will always look for either the Q8 DLLs everytime or Q16 DLLs everytime. This will cause your application to crash when the wrong pixel quantization libraries are used. It is thus safer to copy the CORE_RL*.DLLs to your application folder.

Note that this also applies to the IM_MOD_RL*.dll files as well.

I hope this gets you going,

Kent

Jul 27, 2011 at 6:17 PM

Hi Kent,

Thanks for the prompt reply. I understand the requirement to have the Core_rl DLLs in the same folder as the application. When I try to add the DLLs as reference they are not recognized by Visual Studio 2005 as valid components. Sure I can copy the DLLs to the bin folder of my project. However the application is deployed to multiple machines using ClickOnce deployment. I need to package the DLLs in the deployment. Now I'm sure I'm missing something very obvious but it is my understanding that you can only add files to the deployment if they are referenced by the project and since I can't reference the DLLs I can't add them in the deployment.

Is there a way to ensure that the ClickOnce deployment bundles the CORE_RL*.DLLs and IM_MOD_RL*.dll files with the application? 

Thanks

Pseudo

Jul 27, 2011 at 6:23 PM

Pseudo,

Ok, I see your problem now.  I don't use OneClick deployment very often/at all so I can't offer any additional help.  We have server based apps here so I just copy the files directly to the install folder.

Kent

Jul 27, 2011 at 11:17 PM
Regarding clickonce and native dlls. You can embed the dlls as resources, as you would an image file, in your .net assembly. Then copy the dlls to the working directory at runtime. I've used this technique several times before.

Sent from my iPad
Aug 3, 2011 at 8:21 PM

I was able to get all the DLLs in the same folder as the exe using ClickOnce by setting the Copy to Output property to Copy Always and setting the Build Action to Content. However now I'm getting the following exception.

System.IO.FileLoadException: A procedure imported by 'ImageMagickNET, Version=1.0.3484.35397, Culture=neutral, PublicKeyToken=null' could not be loaded. File name: 'ImageMagickNET, Version=1.0.3484.35397, Culture=neutral, PublicKeyToken=null' ---> System.Runtime.InteropServices.COMException (0x8007007F): The specified procedure could not be found. (Exception from HRESULT: 0x8007007F) 

The application is a .NET 2.0 WinForms application and I've used the Q16 DLLs. Should I use the Q8 DLLs? What is the difference between the two?

Thanks

Aug 9, 2011 at 11:03 AM

Hello Pseudoname,

i have the same error. if anyone knows how to solve this? please gevi me a clue.

Thnx in advance.

Roel

Aug 9, 2011 at 6:31 PM

Hi rakmoh,

I got it to work. Here's what I did.

1. Get the source code from the link provided by kento above.

2. Get the latest source code from this site.

3. overwrite the source code retrieved from the link by kento with the latest source code from this site.

4. Open the ImageMagick solution file and compile the project.

5. Reference this DLL in your project and you won't get the error.

Hope that helps

Aug 29, 2011 at 10:48 AM

I tried pseudoname's instructions, but it still doesn't work.

First of all, the install_full.bat fails because it can't do regedit on q8.reg because q8.reg can't be found. I searched in the whole source download, and indeed there is no such file anywhere.

I opened the solution in VS 2008.  I did a rebuild the ImageMagickNET project. It calimed that it succeeded, but all sorts of files in the various project directories had icons marked with the European "No Entry" mini-icon (the red disc with the horizontal white stripe).

I then tried building the VBForms project, but that failed with the error message "Error 1 The command "xcopy ..\..\..\DLLs\DebugQ16\*.* . /y" exited with code 4." This is surprising because the directory "DLLs" doesn;t appear anywhere in my directory tree, so its no wonder the copy failed.

I'd really appreciate help. BTW, as I am running Windows7, I made sure I was in admin mode before performing any activity.

TIA

mlavie
"

Sep 27, 2011 at 10:26 PM

Has anyone had any luck getting this library to work? I've tried recompiling multiple version I've found online, but none of them seem to work. I keep getting FileLoadExceptions halting my program from running.

It's a real shame the dev abandoned this project, shifting through the API it seems very intuitive and easy to use, aside from the fact it is near impossible to install.

Nov 16, 2011 at 10:13 PM

I used the compiled DLL I found here :  simply added the it to my project and it worked like a charm!

Did a little digging around and found useful documentation here, reusing this with the DLL is pretty intuitive.

An example of how I resized an image if it is greater than 100x100 pixels :

 MagickNet.Magick.Init();
 MagicNet.Image img = new MagicNet.Image("file.jpg");
 MagickNet.Geometry g = new MagickNet.Geometry("100x100>");
 img.Resize();
 img.Write("newFile.png");
 MagickNet.Magick.Term();

Hope this helps!

Nov 16, 2011 at 10:15 PM

Oops, I have a typo

 img.Resize();
should be
img.Resize(g);

 

Dec 13, 2011 at 3:14 PM

Has anyone been able to successfully run this project on Visual Basic 2008 Express?

Is there any plan to release a new dll with the latest version of IM?

Jan 6, 2012 at 9:11 PM

I would be able to run it. As informed on download page the published version has been built to IM 6.5.3-10

So that's what I did:

- Added a reference to 'ImageMagickNet.dll' in my project;

- Downloaded 'ImageMagick-6.5.3-10-Q160-windows-dll.exe' file from this link: http://image_magick.veidrodis.com/image_magick/binaries/

- After installing it copied all DLL files from 'C:\Program Files\ImageMagick-6.5.3-Q16' to 'bin' folder.

Then ran it without problem.

Rgds

Sep 18, 2012 at 8:32 PM

^^^^^ SO MUCH THIS!!!

Fabiobr's instructions worked perfectly for me, with one little addon, so I'm going to sum up here: (I'm using the 8-bit version... just substitute "16" wherever the instructions refer to "8" below)

1) Download this project and unzip it anywhere.
2) In your project, make a reference to the ImageMagickNET.dll in the bin\Q8 folder.
3) Go to http://image_magick.veidrodis.com/image_magick/binaries/ and download 'ImageMagick-6.5.3-10-Q8-windows-dll.exe'
4) Run the install, accepting all the defaults.
5) Copy ALL the DLL's in C:\Program Files\ImageMagick-6.5.3-Q8 to the ROOT folder of your project. (not the bin folder)
6) Set "Copy to Output Directory" to "Copy always"

If you copy the DLL's to the bin folder, they will not be in the same folder as the executable when you debug (or publish) and will get this error. By copying them to the root folder, they will be copied to the same directory as the executable.

Now if only the help docs were better...

Sep 19, 2012 at 3:02 PM

RE: the docs...

I have found that the COM library that installs by default when you install the binary for Windows uses the EXACT SAME syntax as the command line. This doesn't seem to be possible with ImageMagickNET. So while a .NET wrapper is nice, the lack of documentation (and apparent lack of features) prevented me from using this in my project.

So my recommendation for anyone wanting to implement ImageMagick in their project is to simply bundle the ImageMagick installer with your project and deploy it along with your app.

To use the COM components:

1) Install the newest version of ImageMagick on the computer you're developing with.
2) Add a reference to the COM component "ImageMagickObject" to your application.
3) Import ImageMagickObject in your class. (Imports ImageMagickObject)
4) In your code, declare a new MagickImage object. (Dim VarName As MagickImage)
5) Now use that MagickImage object as if it were a command line. So...
    convert img1.gif img2.jpg -becomes- VarName.convert "img1.gif", "img2.jpg"
6) Use any of the thousands of very helpful and detailed tutorials, help documents and examples on the web!
7) When it comes time to publish, incorporate the ImageMagick installer in your install.

I don't intend to bash this project; it's a great idea and I would love to see some development and documentation but the COM implementation is just more well supported, in my opinion.

Dec 18, 2012 at 3:07 PM

Terrible installation ;-)

So I tried to follow fabior and TheDeekman (thanks for your effort guys), but I'm still getting the FileNotFoundException.

I'm building an ASP.MVC 4 application with Visual Studio 2012.

In short, this is what I did:

  1. I downloaded and installed the binareies and libs for ImageMagickNet from here: http://imagemagick.codeplex.com/releases/view/30302
  2. I downloaded and installed "ImageMagick-6.5.3-10-Q8-windows-dll.exe".
  3. I added a reference to "ImageMagickNet.dll". 
  4. I copied all DLLs from C:\Program Files\ImageMagick-6.5.3-Q8 to my VS project's root folder. However, I just mention that I did not copy the DLLs from C:\Program Files\ImageMagick-6.5.3-Q8\modules\coders and other subfolders. I don't need those, right?
  5. I made a right click on my project and then Add > Existing Item...
  6. Here I picked all the DLLs which I had just copied to my project's root folder (in step 2).
  7. After that, I had 20 new files visible in Visual Studio's Solution Explorer. It's 14 files starting with CORE_RL_..., also mfc90.dll, msvcp90.dll, msvcr90.dll, vcomp90.dll, X11.dll and Xext.dll.
  8. I selected these 20 files, went to the Properties Pane and set "Copy to Output Directory" to "Copy always".
  9. I started my application by hitting F5.
  10. My browser comes up and shows the "yellow screen" with the error message (Could not load file or assembly 'ImageMagickNET.dll' or one of its dependencies. The specified module could not be found.)

Can any of you guys tell if I missed something?

Dec 18, 2012 at 3:30 PM

The key is that the .dll's publish to the same directory as the .exe.

When you "Build" check the directory that is generated. Ensure that all the dlls are in the same directory as your .exe

If that's the case, then I would say you have a missing dll.

Good luck!

-Deek

Dec 18, 2012 at 5:32 PM

Hey Deek,

thanks for your help. Well, afaik there is no *.exe for web applications ;-)

But I can confirm that all DLLs were copied to the /bin folder when I compiled the project. So, the DLLs are located both in the root folder of my project AND in the corresponding /bin folder.

In case I am missing a DLL...I have no idea how to figure out which one it might be.

Damn, I was really hoping to be able to integrate ImageMagickNet.

Cheers
Ingmar 

Dec 19, 2012 at 9:11 AM

Are you using the correct ImageMagickNET.dll? If you download 'ImageMagick-6.5.3-10-Q8-windows-dll.exe', you should use the ImageMagickNET.dll from the bin\ReleaseQ8 directory.

If it is possible you could also install the '.exe' on your webserver. Then you won't need to copy any of the dll's to the bin directory.

Dec 19, 2012 at 9:27 AM

Hi dlemstra,

thanks for your help as well.

Yes, I am using the Q8 version of ImageMagickNET. And I just re-installed everything one more time. This time I checked "Install ImageMagickObject OLE Control for VBScript, Visual Basic, and WSH" in ImageMagick's setup program. As result I got another DLL in the installation's root folder: "ImageMagickObject.dll". I copied this new DLL to the other 20 DLLs in my project. 

But still: error message on Run.

So far I haven't even tried my web server. I'm still fiddling around on my local development machine.

Dec 19, 2012 at 10:27 AM

When you check 'Add application directory to your system path' during the installation you don't have to copy the dll's.

- Is your 'target  platform' x86?

- If you are using the cassini webserver to start your project? You could try switching to IIS7.

Dec 19, 2012 at 10:50 AM

Yes, I checked 'Add application directory to your system path' during ImageMagick's installation. But good to know that I don't have to copy the DLLs then. And yes, my target platform is x86. And I have been trying both Visual Studio Development Server and local IIS Web Server. I'm not using Cassini.

If I just knew which DLL is missing or can't be found. Stupid thing ;-)


Dec 19, 2012 at 1:26 PM
Edited Dec 19, 2012 at 1:27 PM

Sorry, I missed the ASP MVC reference. Use the line below to get the executable path for your MVC app. If you drop the DLL's there, that might do it.

Path.GetDirectoryName(Application.ExecutablePath)

-Deek

Dec 19, 2012 at 1:36 PM

Sorry, Deek, but Application.ExecutablePath in a web application? I believe this only works for WinForms or console apps...no?

I mean, I know the path where all the DLLs go when I run the application.
And the 21 DLLs I mentioned are all in there.
Additionally to the default Microsoft and MVC DLLs. 

So, I believe it is not a question of the path, but rather ... something else. Maybe I am still missing a DLL? That's why I listed all the DLLs I imported to my project. If you have a running project with ImageMagick, and you could check which DLLs exactly it contains, that would be awesome. 

Thx!

Ingmar

Dec 19, 2012 at 2:20 PM

I actually abandoned ImageMagickNET first for the COM implementation of ImageMagick then for the .NET image manipulation classes at System.Drawing.

Check out the following:

System.Drawing
System.Drawing.Imaging
System.Drawing.Drawing2D
System.Drawing.Text

-Deek

Dec 20, 2012 at 9:02 AM

Well, thanks. Unfortunately this does not help me much. I need ImageMagick for just one purpose: convert *.eps to *.jpg. And as far as I know ImageMagick is the only library able to do so. Ah, no, there is ImageGlue as well. Maybe I should checkout this one.

Thanks for all your help and support guys! 

Dec 21, 2012 at 1:25 PM
Edited Dec 21, 2012 at 1:26 PM

I did a similar project (as a web service) where I take in an image and convert it to JPG. Only come across a few issues. I do recall getting an error similar to yours. Once I rebooted my pc after the install, everything was cleared up. http://imagemagick.codeplex.com/discussions/257915.

 


Jul 22, 2013 at 8:03 PM
Edited Jul 22, 2013 at 8:06 PM
I've inherited a C# project (VS 2010) from another developer who has inserted imageMagick into his work. I'm having a terrible time getting my dev environment set up to recognize/run this thing. This is the error message I got with the original code:

Could not load file or assembly 'Magick.NET-x64' or one of its dependencies. An attempt was made to load a program with an incorrect format.

After struggling for a few hours, I finally deleted all references to imageMagick in the project & deleted the dll from the bin folder. The project wouldn't run, of course. I re-installed imageMagick using the NuGet tool & got the same error as before. NuGet put a config file in my main folder, but did not put a dll in the bin folder, so I copied the appropriate dll to the bin folder & now I get this error:

A procedure imported by 'ImageMagickNET.DLL' could not be loaded.

Until I resolve this, I can't even get the project open. Any ideas would be appreciated.

Thanks!
Jul 23, 2013 at 7:59 AM
It looks like you are combing this wrapper with the new wrapper (Magick.NET). When you receive the message 'Could not load file or assembly 'Magick.NET-x64' or one of its dependencies. An attempt was made to load a program with an incorrect format.' you are trying to load a 64bit dll into a 32bit environment. You should change your project to target x64 instead of AnyCPU or x86.

If you need more help you can go here: https://magick.codeplex.com/
Jul 23, 2013 at 7:28 PM
Edited Jul 23, 2013 at 10:55 PM
I think this may be a setup issue, not an imageMagick issue. The title of the error is this:

Server Error in '/' Application.

Could not load file or assembly 'ImageMagickNET.DLL' or one of its dependencies. is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

Note that there is no application name in the title or the message text. It looks to me like it's not finding the app. I think I need to change a url or something.

Thank you for your quick response. I'll update when I get it figured out.
Jul 24, 2013 at 3:47 PM
ImageMagickNET.DLL is a library from this package. The dll Magick.NET-x64 is from the Magick.NET project. It looks like you are mixing libraries from different projects.
Jul 26, 2013 at 8:49 PM
Edited Jul 26, 2013 at 10:07 PM
Yes that is what I had done. I have set the project back to the original version & still cannot load the program. Magick.NET-x64.dll is in my bin folder. I've also tried to install via 'Manage NuGet Packages" & get the same error.

Here is the error message:


Server Error in '/' Application.

Could not load file or assembly 'Magick.NET-x64' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Magick.NET-x64' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Magick.NET-x64' could not be loaded.

=== Pre-bind state information ===
LOG: User = laptop\lh
LOG: DisplayName = Magick.NET-x64
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Magick.NET-x64 | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/LH/Computers/WebDev/vs/myProject/
LOG: Initial PrivatePath = C:\LH\Computers\WebDev\vs\myProject\bin
Calling assembly : (Unknown).
Jul 29, 2013 at 7:40 AM
Did you change your platform target to x64? And you should probably ask your questions here: https://magick.codeplex.com/discussions
May 23, 2014 at 4:25 PM
Hi there,

did someone found a solution for this error: "System.IO.FileLoadException" Unable to load procedure imported by 'ImageMagickNET.dll' ?
I did all the things said on this thread, but I'm still getting this error.

I'm using Visual Studio 2013 on Windows 8.1, imported the ImageMagickNET.dll as a reference (tried with the ImageMagickObject.dll as well), installed "ImageMagick-6.8.9-1-Q16-x86-dll.exe" (compiled the project as x86) but I can't even call "InitializeMagick()" in my program without this showing up...

If someone found something to do with this problem, I would be sincerely grateful.
May 23, 2014 at 5:29 PM
I never got it to work. I had two other .NET developers look at it too & they couldn't get it to work. I was using Studio 12 & Win 7 at the time. Good luck. If you figure it out. please post back. I still have the project on my laptop.
May 24, 2014 at 1:33 PM
As posted earlier I have created a new wrapper called Magick.NET. This library does not require you to also install ImageMagick on your machine. You can find that project here: https://magick.codeplex.com/.
May 26, 2014 at 1:28 PM
Can't get it to work too, I'm now using Magick.NET which works!
Thank's dlemstra for your work! ;)