PDA

View Full Version : ImageMagick and Visual Studio


mindsample
07-02-2009, 02:57 PM
Hi,

got another one of those non-interesting problems that is bugging me almost to death. I am using the CImg library for some Image Processing fun and ran into some functionality which requires ImageMagick. I downloaded the windows .exe installer, it all went fine, but when I try and run my code I get weird error messages:


#include <iostream>
#include "CImg.h"
using namespace cimg_library;

int main() {
CImg<unsigned char> image("lena.jpg"), visu(500,400,1,3,0);

which is just supposed to load that jpg (in the same directory) but instead I get this error message, i.e. the jpg support is not working?!

--
convert.exe: unable to open image 'C:\DOCUME~1\mt\Local':Permission denied ' blob.c/OpenBlob/2476
Invalid Parameter - C:\DOCUME~1\mt\Local `gm.exe is not recognized as an internal or external command, operable program or batch file.

and also a CImgIOException CImg,unsigned char>::load(): File 'lena.jpg', format not recognized.
--

I dont understand where the permission problem is supposed to come from?
Also, what is this gm.exe ? Am I missing something obvious? Also apart from running the windows executable for ImageMagick, does anybody know if I need to do anything else to get this working in Visual Studio 2005?

UrbanFuturistic
07-02-2009, 04:36 PM
1) Don't put ImageMagick in a path with spaces (this is a depressingly common issue with ports from Linux) (source (http://gallery.menalto.com/node/55383)).
2) Put libjpeg (and libpng, etc.) where ImageMagick can find them. In its own directory is good, in Windows\System32\ is probably better. It is, again, common for a lot of programs like this to rely on these external libs but not include them.

Of course, if these don't work I may be guessing at a couple of things.

mindsample
07-03-2009, 09:07 AM
Thanks - I dont have it in a path with spaces, I was aware of that link already. I also followed this:

http://www.imagemagick.org/script/install-source.php

step by step and finished building VisualStaticMT successfully. However when I go into my Project I still get the same error messages.

Have you got any other ideas?

mindsample
07-03-2009, 10:55 AM
Okay, update for my monolog so far: I copied all the Magick++ .h files into my VC include directory so they can be found. Then I compiled a few times, further adding files that the program couldnt find, i.e. wand, magick and Magick++ folders. Which is obviously what I should have done in the first place as I am after the API ... d'oh!

Now I dont get any "not found" error messages anymore when compiling, however something new came up and I dont understand why.

This is soooooooo frustrating ...


1>Compiling...
1>main.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(245) : error C2039: 'PolynomialDistortion' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(245) : error C2873: 'PolynomialDistortion' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(247) : error C2039: 'PolarDistortion' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(247) : error C2873: 'PolarDistortion' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(248) : error C2039: 'DePolarDistortion' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(248) : error C2873: 'DePolarDistortion' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(249) : error C2039: 'BarrelDistortion' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(249) : error C2873: 'BarrelDistortion' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(250) : error C2039: 'BarrelInverseDistortion' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(250) : error C2873: 'BarrelInverseDistortion' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(251) : error C2039: 'ShepardsDistortion' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(251) : error C2873: 'ShepardsDistortion' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(252) : error C2039: 'SentinelDistortion' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(252) : error C2873: 'SentinelDistortion' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(459) : error C2039: 'SparseColorMethod' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(459) : error C2873: 'SparseColorMethod' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(460) : error C2039: 'UndefinedColorInterpolate' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(460) : error C2873: 'UndefinedColorInterpolate' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(461) : error C2039: 'BarycentricColorInterpolate' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(461) : error C2873: 'BarycentricColorInterpolate' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(462) : error C2039: 'BilinearColorInterpolate' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(462) : error C2873: 'BilinearColorInterpolate' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(463) : error C2039: 'PolynomialColorInterpolate' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(463) : error C2873: 'PolynomialColorInterpolate' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(464) : error C2039: 'ShepardsColorInterpolate' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(464) : error C2873: 'ShepardsColorInterpolate' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(465) : error C2039: 'VoronoiColorInterpolate' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(465) : error C2873: 'VoronoiColorInterpolate' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(516) : error C2039: 'HorizontalTileVirtualPixelMethod' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(516) : error C2873: 'HorizontalTileVirtualPixelMethod' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(517) : error C2039: 'VerticalTileVirtualPixelMethod' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(517) : error C2873: 'VerticalTileVirtualPixelMethod' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(518) : error C2039: 'HorizontalTileEdgeVirtualPixelMethod' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(518) : error C2873: 'HorizontalTileEdgeVirtualPixelMethod' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(519) : error C2039: 'VerticalTileEdgeVirtualPixelMethod' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(519) : error C2873: 'VerticalTileEdgeVirtualPixelMethod' : symbol cannot be used in a using-declaration
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(520) : error C2039: 'CheckerTileVirtualPixelMethod' : is not a member of 'MagickCore'
1>C:\Program Files (x86)\Microsoft Visual Studio 8\VC\include\Include.h(520) : error C2873: 'CheckerTileVirtualPixelMethod' : symbol cannot be used in a using-declaration
1>c:\program files (x86)\microsoft visual studio 8\vc\include\Magick++/Color.h(367) : error C2653: 'MagickLib' : is not a class or namespace name
1>c:\program files (x86)\microsoft visual studio 8\vc\include\Magick++/Color.h(367) : error C2833: 'operator PixelPacket' is not a recognized operator or type
1>c:\program files (x86)\microsoft visual studio 8\vc\include\Magick++/Color.h(368) : error C2270: '<Unknown>' : modifiers not allowed on nonmember functions
1>c:\program files (x86)\microsoft visual studio 8\vc\include\Magick++/Color.h(368) : error C2244: 'Magick::Color' : unable to match function definition to an existing declaration
1>c:\program files (x86)\microsoft visual studio 8\vc\include\Magick++/Color.h(368) : fatal error C1903: unable to recover from previous error(s); stopping compilation
1>Build log was saved at "file://d:\BuildLog.htm"
1>MyProject - 43 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========




the program I am attemptin to run is like this:


#include <CImg.h>
#include <Magick++.h>
#include <iostream>
using namespace cimg_library;

int main()
{

CImg<double> image("lena.jpg");
CImgDisplay main_disp(image, "Image",0);

return 0;
}

UrbanFuturistic
07-03-2009, 11:31 AM
I think you also need:

using namespace Magick;
using namespace std;

This might be a bit useful http://www.graphicsmagick.org/Magick++/Image.html

mindsample
07-03-2009, 11:32 AM
Another Update. I added the files to a path with no spaces, added the directories to my VC paths so they can be found and everythign compiles now. However I am still getting the same error messages when running the file:

No permission, gm.exe not found etc.

Sigh ...

mindsample
07-03-2009, 12:07 PM
Thanks again!

I can't follow anymore. gm.exe is part of graphics magick according to some google search but i never actually downloaded or installed anything but the original ImageMagick. I ran all sorts of

cacls commands to adjust priorities but as far as I am concerned I now officially ran out of ideas. I can compile but I cannot load images without receiving those error messages ..

UrbanFuturistic
07-03-2009, 12:19 PM
It's possible I suppose that you've downloaded the API for gm instead of IM. You could always try downloading gm. :shrug:

Benr
07-03-2009, 05:08 PM
Just curious what functionality you need Image Magick for. Maybe there's an alternative.

mindsample
07-05-2009, 10:46 AM
I require CImg to be able to load .jpg and other file formats such as .sgi - as per CImg the ImageMagick package is the way to go?

UrbanFuturistic
07-05-2009, 12:18 PM
Is there a specific reason you require cimg? Is there another part of the program that is specifically dependent on this? If not, I'd look foremost at what is recommended for IM/GM. As always, there are many libs which perform these basic functions.

GraphicsMagick is a fork of ImageMagick which may or may not be more suitable for your purposes but while these are similar, they're not binary compatible.

From what I can see so far it's possible you've downloaded the API for GM rather than IM which wouldn't necessarily be too difficult if your weren't expecting them to be so stupid as to have the same names and namespaces (Magick++ for IM (http://www.imagemagick.org/Magick++/) and Magick++ for GM (http://www.graphicsmagick.org/Magick++/index.html)).

Without seeing exactly what you've got or where you've downloaded from, the only things I can suggest are to either rip out the API files you have installed and replace with a download directed from the ImageMagick site or download GraphicsMagick and use that instead.

mindsample
07-06-2009, 09:29 AM
Thanks again for your reply.

I am almost certain that I have not downloaded GM at any point. I am still trying to understand where the gm.exe requirment comes from.

To answer your question: I dont per se require CImg, I just want to use an image processing library that I can build upon and CImg seems to be a good choice. I am happy to use another one if you have suggestions. Basically I want CImg and then noticed (as a complete novice) that I can't actually just "load" a .jpg or .sgi into my application, I need something additional to CImg.

The reason I am using VS is because I later want to start writing for Maya - so I figured I should start where I will end up anyways. Maybe this is making it all too difficult ...

If you have another suggestion ...

Benr
07-07-2009, 03:50 PM
Well if you do feel like trying something else, I've had pretty good experience with FreeImage. Also, while it has a different focus, I've found the image and video tools in OpenCV to be very stable.

mindsample
07-08-2009, 12:55 PM
Its working now ... I had an issue with my windows temp directory. Not that any of the error messages pointed towards that at all.
The temp diretory GraphicsMagick/ImageMagick was using upon debugging was in my Documents and Settings, which causes problems due to the spaces. Changing the Windows Environment Variables to C:\temp did the trick. Sigh ...

Thanks to all of your for hanging in there. What a nightmare ...

UrbanFuturistic
07-08-2009, 04:55 PM
It's possible there's been some cross-pollution with error messages betweeen GM and IM I suppose. Code could have been taken from the former. Just guessing here though.

Assuming you're looking to do plug-in development with Maya you could also look into Paint.Net (http://www.getpaint.net/). There's a pretty large plugin forum (http://paintdotnet.forumer.com/viewforum.php?f=27&sid=8a820d91f7d200a838fcd5768ed62dca).

Of course, I have no idea if this really suits what you want to do.

CGTalk Moderation
07-08-2009, 04:55 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.