io.plugins freeimage installation issue?

622 views
Skip to first unread message

Sigmund

unread,
Jan 25, 2012, 8:01:19 PM1/25/12
to scikits-image, ste...@sun.ac.za
Hallo!
I'm using the freeimage plugin for reading uint8 and float32 Grey-
scale TIFF files. The aim is some basic x-ray diffraction image
processing. The development is done on MacOSX but some users are Win
users. To make it short. The freeimage imread on Windows isn't
working. Since it is working on the Mac and I had a hard time getting
freeimage installed. I think I might have done something wrong during
installation.
The readme file from FreeImage didn't help much. So some questions:

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)

I ended up with having a successful run of the test_freeimage.py and a
ValueError for the TIFF files on the Windows machin.

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

Thanks!

Siggi

Zachary Pincus

unread,
Jan 25, 2012, 9:34:27 PM1/25/12
to scikit...@googlegroups.com
Hi Siggi,

> 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

Sigmund

unread,
Jan 26, 2012, 9:10:00 AM1/26/12
to scikits-image
First, thank you for your answer!

Since I'm not in my office today I tried to do the same at my BootCamp
Win 7 64 Partition. Here I encountered a new problem.
If I run the "test_freeimage.py" I get the error that the "OSError:
Could not find libFreeImage in any of the following directories:"(full
error output below). But I'm sure that it is in the right folder and
that "python_freeimage.py" is looking in the right pace. How can that
be?
First idea was that "sys.platform" is returning "win64" instead of
"win32" but it isn't. I also tried changing the case of the
"FreeImage.dll" but didn't help. So as far I could check, everything
is going right, but it is still not taking the FreeImage.dll.

Running it on the BootCamp machine is not necessary for me but it
might be of interest for you.

I will get back to the first post tomorrow.

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'
"""



Siggi

Zachary Pincus

unread,
Jan 26, 2012, 1:12:05 PM1/26/12
to scikit...@googlegroups.com

> Since I'm not in my office today I tried to do the same at my BootCamp
> Win 7 64 Partition. Here I encountered a new problem.
> If I run the "test_freeimage.py" I get the error that the "OSError:
> Could not find libFreeImage in any of the following directories:"(full
> error output below). But I'm sure that it is in the right folder and
> that "python_freeimage.py" is looking in the right pace. How can that
> be?

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

Christoph Gohlke

unread,
Jan 26, 2012, 1:41:22 PM1/26/12
to scikit...@googlegroups.com

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


Zachary Pincus

unread,
Jan 26, 2012, 1:51:33 PM1/26/12
to scikit...@googlegroups.com
> 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.

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

Sigmund

unread,
Jan 26, 2012, 2:18:15 PM1/26/12
to scikits-image
I first uninstalled the old version and than installed the new one.
Still the same problem.


>pythonw -u "readHASYLAB.py"
Traceback (most recent call last):
File "readHASYLAB.py", line 5, in <module>
io.use_plugin("freeimage", "imread" )
File "C:\Python27\lib\site-packages\skimage\io\_plugins\plugin.py",
line 124, in use
_load(name)
File "C:\Python27\lib\site-packages\skimage\io\_plugins\plugin.py",
line 180, in _load
fromlist=[modname])
File "C:\Python27\lib\site-packages\skimage\io\_plugins
\freeimage_plugin.py", line 99, in <module>
'directories: \'%s\'' % '\', \''.join(lib_dirs))
OSError: Could not find libFreeImage in any of the following
directories: 'C:\Python27\lib\site-packages\skimage\io\_plugins', '/
lib', '/usr/lib', '/usr/local/lib', '/opt/local/lib'
>Exit code: 1

here is the command window response...


C:\Users\Siggi>dir C:\Python27\lib\site-packages\skimage\io\_plugins
Volume in Laufwerk C: hat keine Bezeichnung.
Volumeseriennummer: CC91-F951

Verzeichnis von C:\Python27\lib\site-packages\skimage\io\_plugins

26.01.2012 20:05 <DIR> .
26.01.2012 20:05 <DIR> ..
24.10.2011 18:16 89 fits_plugin.ini
24.10.2011 18:16 4.488 fits_plugin.py
26.01.2012 20:05 4.241 fits_plugin.pyc
26.01.2012 20:05 4.241 fits_plugin.pyo
08.08.2011 08:25 3.417.600 FreeImage.dll
24.10.2011 18:16 92 freeimage_plugin.ini
24.10.2011 18:16 16.187 freeimage_plugin.py
26.01.2012 20:05 15.893 freeimage_plugin.pyc
26.01.2012 20:05 15.884 freeimage_plugin.pyo
24.10.2011 18:16 90 gdal_plugin.ini
24.10.2011 18:16 415 gdal_plugin.py
26.01.2012 20:05 721 gdal_plugin.pyc
26.01.2012 20:05 721 gdal_plugin.pyo
24.10.2011 18:16 91 gtk_plugin.ini
24.10.2011 18:16 1.709 gtk_plugin.py
26.01.2012 20:05 2.188 gtk_plugin.pyc
26.01.2012 20:05 2.188 gtk_plugin.pyo
24.10.2011 18:16 105 matplotlib_plugin.ini
24.10.2011 18:16 80 matplotlib_plugin.py
26.01.2012 20:05 443 matplotlib_plugin.pyc
26.01.2012 20:05 443 matplotlib_plugin.pyo
24.10.2011 18:16 91 null_plugin.ini
24.10.2011 18:16 348 null_plugin.py
26.01.2012 20:05 815 null_plugin.pyc
26.01.2012 20:05 815 null_plugin.pyo
24.10.2011 18:16 100 pil_plugin.ini
24.10.2011 18:16 2.886 pil_plugin.py
26.01.2012 20:05 3.423 pil_plugin.pyc
26.01.2012 20:05 3.371 pil_plugin.pyo
24.10.2011 18:16 5.727 plugin.py
26.01.2012 20:05 6.026 plugin.pyc
26.01.2012 20:05 6.026 plugin.pyo
24.10.2011 18:16 105 qt_plugin.ini
24.10.2011 18:16 5.091 qt_plugin.py
26.01.2012 20:05 5.471 qt_plugin.pyc
26.01.2012 20:05 5.471 qt_plugin.pyo
24.10.2011 18:16 11.991 q_color_mixer.py
26.01.2012 20:05 10.638 q_color_mixer.pyc
26.01.2012 20:05 10.638 q_color_mixer.pyo
24.10.2011 18:16 4.818 q_histogram.py
26.01.2012 20:05 5.159 q_histogram.pyc
26.01.2012 20:05 5.159 q_histogram.pyo
03.12.2011 14:28 8.041 scivi.py
26.01.2012 20:05 9.206 scivi.pyc
26.01.2012 20:05 9.206 scivi.pyo
24.10.2011 18:16 222 test_freeimage.py
26.01.2012 20:05 494 test_freeimage.pyc
26.01.2012 20:05 494 test_freeimage.pyo
24.10.2011 18:16 86 test_plugin.ini
24.10.2011 18:16 483 test_plugin.py
26.01.2012 20:05 1.204 test_plugin.pyc
26.01.2012 20:05 902 test_plugin.pyo
24.10.2011 18:16 13.238 util.py
26.01.2012 20:05 16.760 util.pyc
26.01.2012 20:05 16.680 util.pyo
05.12.2011 12:42 67.584 _colormixer.pyd
05.12.2011 12:42 44.032 _histograms.pyd
24.10.2011 18:16 21 __init__.py
26.01.2012 20:05 185 __init__.pyc
26.01.2012 20:05 185 __init__.pyo
60 Datei(en), 3.771.101 Bytes
2 Verzeichnis(se), 1.931.431.936 Bytes frei

C:\Users\Siggi>



An other good idea?

Christoph Gohlke

unread,
Jan 26, 2012, 2:45:34 PM1/26/12
to scikit...@googlegroups.com
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

Zachary Pincus

unread,
Jan 26, 2012, 2:57:25 PM1/26/12
to scikit...@googlegroups.com
Hi Siggi,

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

Zachary Pincus

unread,
Jan 26, 2012, 3:00:26 PM1/26/12
to scikit...@googlegroups.com
On Jan 26, 2012, at 2:45 PM, Christoph Gohlke wrote:

> 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

Stéfan van der Walt

unread,
Jan 26, 2012, 3:17:07 PM1/26/12
to scikit...@googlegroups.com
On Thu, Jan 26, 2012 at 11:57 AM, Zachary Pincus
<zachary...@yale.edu> wrote:
> 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

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

Christoph Gohlke

unread,
Jan 26, 2012, 3:41:55 PM1/26/12
to scikit...@googlegroups.com

Sigmund

unread,
Jan 26, 2012, 4:28:49 PM1/26/12
to scikits-image
Thanks to you all it works now!

-- with the version of "scikits-image-0.4.2.win-amd64-py2.7" from
Christoph on: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikits-image

-- and the " VC90 Open" runtime from
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=2092

it works!

The initial problem is solve too. It' wasn't platform dependent. Just
my fault.


Thanks a lot guys!

Stéfan van der Walt

unread,
Jan 26, 2012, 5:34:01 PM1/26/12
to scikit...@googlegroups.com
On Thu, Jan 26, 2012 at 1:28 PM, Sigmund <sig...@gmail.com> wrote:
> Thanks to you all it works now!
>
> -- with the version of "scikits-image-0.4.2.win-amd64-py2.7" from
> Christoph on: http://www.lfd.uci.edu/~gohlke/pythonlibs/#scikits-image
>
> -- and the " VC90 Open" runtime from
> http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=2092
>
> it works!

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

Sigmund

unread,
Jan 26, 2012, 5:59:04 PM1/26/12
to scikits-image

> Just to verify: is the last runtime bundled with Chris's
> package or not?

no its not. Without the separate download of the VC90 Open thing, it
did not work.


Siggi

Christoph Gohlke

unread,
Jan 26, 2012, 8:11:23 PM1/26/12
to scikit...@googlegroups.com

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

Stéfan van der Walt

unread,
Jan 26, 2012, 9:30:01 PM1/26/12
to scikit...@googlegroups.com
On Thu, Jan 26, 2012 at 5:11 PM, Christoph Gohlke <cjgo...@gmail.com> wrote:
> I'll rebuild FreeImage without OpenMP support and upload new skimage
> installers that should be easier to distribute to systems without OpenMP
> runtime.

Thanks, Christoph! I removed the instruction to download the runtime
for the time being.

Stéfan

Reply all
Reply to author
Forward
0 new messages