> 1. Do I have to build the freeimage.dll or can I just use the compiled
> one? (didn't make it to compile)
> 2. Is just dropping the .dll in the _plugins Folder all I need to do?
> (thats basically all I did after trying 1. all day)
Sorry for your frustrating day. Your idea for #2 is be correct -- just drop the pre-compiled DLL into _plugins.
(Aside: I've opened a ticket on github regarding other locations that the code should look for the FreeImage DLL. There are obvious candidates on OS X/Linux, but I don't know if there's something akin to /usr/lib/ or whatnot on windows... We should obviously also beef up the documentation about where to get and put FreeImage.)
> I ended up with having a successful run of the test_freeimage.py and a
> ValueError for the TIFF files on the Windows machin.
So test_freeimage.py works fine for you on Windows? That's good, and indicates (among other things) that the DLL is in the right place, and that FreeImage can open PNG files fine.
Now, could you describe precisely the way that you're able to cause the below error? Also, the EXACT same code works fine on OS X but fails on windows?
It would be great if you could pare down the failing code to provide a small, self-contained example that you could post, including code and the image you're trying to load?
From the below error, though, it looks like you're passing in a bad filename to imread -- the error is that you're trying to open a file named "E", and FreeImage can't tell what file type it is (this error also occurs if the file doesn't exist...)
> Error output:
> File "00PeakWIN.py", line 32, in <module>
> img_for_dimentions = array(io.imread(bild, plugin="freeimage" ),
> dtype=int)
> File "C:\Python27\lib\site-packages\scikits_image-0.4.2-py2.7-
> win32.egg\skimage\io\_io.py", line 72, in imread
> img = call_plugin('imread', fname, plugin=plugin, **plugin_args)
> File "C:\Python27\lib\site-packages\scikits_image-0.4.2-py2.7-
> win32.egg\skimage\io\_plugins\plugin.py", line 88, in call
> return func(*args, **kwargs)
> File "C:\Python27\lib\site-packages\scikits_image-0.4.2-py2.7-
> win32.egg\skimage\io\_plugins\freeimage_plugin.py", line 512, in
> imread
> img = read(filename)
> File "C:\Python27\lib\site-packages\scikits_image-0.4.2-py2.7-
> win32.egg\skimage\io\_plugins\freeimage_plugin.py", line 282, in read
> bitmap = _read_bitmap(filename, flags)
> File "C:\Python27\lib\site-packages\scikits_image-0.4.2-py2.7-
> win32.egg\skimage\io\_plugins\freeimage_plugin.py", line 326, in
> _read_bitmap
> raise ValueError('Cannot determine type of file %s' % filename)
> ValueError: Cannot determine type of file E
Zach
That is indeed odd. You're certain that FreeImage.dll is in:
C:\Python27\lib\site-packages\scikits_image-0.4.2-py2.7-win-amd64.egg\skimage\io\_plugins
Could you pop up a command window and paste the following in, just to double-check:
dir C:\Python27\lib\site-packages\scikits_image-0.4.2-py2.7-win-amd64.egg\skimage\io\_plugins
> By the way, it might be better and I think easy to change if the error
> "OSError: Could not find libFreeImage in any of the following
> directories:" is using the OS specific library name. Thats easier to
> understand for people like me that not relay know what they are doing.
>
> """
> OSError: Could not find libFreeImage in any of the following
> directories: 'C:\Python27\lib\site-packages\scikits_image-0.4.2-py2.7-
> win-amd64.egg\skimage\io\_plugins', '/lib', '/usr/lib', '/usr/local/
> lib', '/opt/local/lib', 'C:\Users\Siggi\lib'
> """
Definitely. All of the FreeImage loading stuff is still far too *NIX specific, in the search paths and also the errors. I'll try to fix that up.
Zach
You are running a 64 bit version of Python. Please verify that the
FreeImage.dll is also 64 bit. You may want to try
scikits-image-0.4.2.win-amd64-py2.7.exe from
<http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikits-image>, which
includes a 64 bit FreeImage.dll.
Christoph
Good call, Christoph. I've verified that the FreeImage DLL available for download from the FreeImage site is 32-bit only. (Can one make "fat" 32/64-bit DLLs on Windows?)
Siggi, probably the best option is to follow Christoph's advice and grab his packages. That's probably the easiest way to get you and your users to have a working scikits-image install.
Zach
The 64 bit FreeImage.dll depends on the VC90 OpenMP runtime. I'm not
sure Python installs the full VC90 redistributable package or just the
CRT. The full installer, including OpenMP, can be obtained at
<http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=2092>.
Christoph
First, again sorry for all the trouble!
Now, Christoph correctly pointed out that if you're using a 64-bit version of python, you need a 64-bit build of the FreeImage DLL. Unfortunately, the DLL provided by the FreeImage website is 32-bit only. Fortunately, Christoph provides 64-bit builds of scikits-image:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikits-image
(It appears that you want scikits-image-0.4.2.win-amd64-py2.7.exe .)
Now, to clarify things:
> I first uninstalled the old version and than installed the new one.
What do you mean exactly by "the new one"? Is that a new scikits-image build (e.g. from Christoph?)? A new FreeImage DLL (from Christoph or another source)?
First, you need to let us know whether your python 2.7 is 32- or 64-bit... you would have downloaded one or the other installer from Python.org. If you don't recall this, then start up python and type:
import sys
print sys.maxsize > 2**32
If the result is "True" then you have a 64-bit build of python and you will need to get Christoph's 64-bit scikits-image build, which contains a 64-bit FreeImage DLL. If "False", then you should either use Christoph's 32-bit build, or install your own scikits-image and use the 32-bit FreeImage DLL provided by the FreeImage site.
Hope this is clear; if not please don't hesitate to ask me anything.
Zach
> On 1/26/2012 11:18 AM, Sigmund wrote:
>> I first uninstalled the old version and than installed the new one.
>> Still the same problem.
>
> The 64 bit FreeImage.dll depends on the VC90 OpenMP runtime. I'm not sure Python installs the full VC90 redistributable package or just the CRT. The full installer, including OpenMP, can be obtained at <http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=2092>.
>
> Christoph
Oh ugh, what a pain!
I will try to beef up the error-handling in freeimage_plugin so that it doesn't just say "no file found", but prints proper diagnostics for when it finds but cannot load a library.
Sorry you're in the role of windows-bugfinder, Siggi! I don't have personal access to all the permutations of windows, so my testing on this has been obviously a bit spotty.
Zach
These had been linked on the downloads webpage a while ago, but I
forgot to rebuild.
http://scikits-image.org/download.html
Cheers
Stéfan
Excellent! Just to verify: is the last runtime bundled with Chris's
package or not? I'd like to update the installation instructions to
help others following the same route.
Stéfan
Just wanted to confirm this: by default OpenMP is used by the LibRAW
component of FreeImage, in 64 bit mode only. OpenMP DLLs are part of the
VC90 runtime installer. The Python installer only includes the C, not
the OpenMP, part of the whole VC90 runtime.
I'll rebuild FreeImage without OpenMP support and upload new skimage
installers that should be easier to distribute to systems without OpenMP
runtime.
Christoph
Thanks, Christoph! I removed the instruction to download the runtime
for the time being.
Stéfan