Trying to get FreeImagePy to work.

I

Iain King

I've installed ctypes and FreeImagePy. When I do this:

I get:
find
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "C:\Python\Lib\site-packages\FreeImagePy\FreeImagePy.py", line
1952, in _
_init__
super(Image, self).__init__(libraryName)
File "C:\Python\Lib\site-packages\FreeImagePy\FreeImagePy.py", line
376, in __
init__
self.__lib = self.__internlLibrary(libraryName)
File "C:\Python\Lib\site-packages\FreeImagePy\FreeImagePy.py", line
313, in __
init__
self.lib = C.windll.find(libraryName)
File "ctypes\__init__.py", line 370, in __getattr__
dll = self._dlltype(name)
File "ctypes\__init__.py", line 296, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Errno 126] The specified module could not be found

I put a 'print self._name' in the ctypes __init__ file, just before
line 296 - it's printing out the 'find' just before the error.
So, in what specific way have I screwed up the install?

Iain
 
M

Michele Petrazzo

Iain said:
I've installed ctypes and FreeImagePy. When I do this:


I put a 'print self._name' in the ctypes __init__ file, just before
line 296 - it's printing out the 'find' just before the error. So, in
what specific way have I screwed up the install?

What's your ctypes version? Is 0.9.9.6? If yes, can you download the
last svn version, that solve that problem (I hope) and add some
functions? If you can't I'll release a new version (1.2.5)

Bye,
Michele
 
I

Iain King

Michele said:
What's your ctypes version? Is 0.9.9.6? If yes, can you download the
last svn version, that solve that problem (I hope) and add some
functions? If you can't I'll release a new version (1.2.5)

I downloaded and installed 0.9.9.3, and it now works. Thanks!

Iain
 
I

Iain King

Michele said:
I advice you to don't use that ctypes version... Better is to use the
newest one and update freeimagepy!


Michele

OK, Ive installed the latest versions I can find, which are FreeImagePy
1.2.4 and ctypes 0.9.9.6, and I'm back to the error I had earlier. Do
you know what's wrong?

Iain
 
M

Michele Petrazzo

Iain said:
OK, Ive installed the latest versions I can find, which are
FreeImagePy 1.2.4 and ctypes 0.9.9.6, and I'm back to the error I had
earlier. Do you know what's wrong?

Iain

Can you download the last svn version from sf.net? Otherwise I'll send
you the last sources privately.

Bye,
Michele
 
I

Iain King

Michele said:
Can you download the last svn version from sf.net? Otherwise I'll send
you the last sources privately.

Bye,
Michele

Sorry, I hadn't heard of SVN before, so I didn't know what you were
talking about earlier :). I got the TortoiseSVN client though, and
checked out your newest build, copied it over the top of
site-packages/freeimagepy, updated my ctypes back to 0.9.9.6 (I'd
regressed again), ran my program, and it worked. Thanks!

Next question (and what I'm using FreeImagePy for): I'm loading a pile
of TIF's as thumbnails into a wx list control. I load the image with
FIPY, convert it to PIL, use PIL's antialiasing thumbnail function,
then load it from there into wx. However, when I'm do the
fipy.convertToPil(), it inverts the image? I've inserted a
fipy.invert() before the conversion as a temporary fix, but is there a
reason for this?
relevant code:

def getHeaders(files):
thumbs = []
for f in files:
print "Adding %s" % f
fi = FIPY.Image(f)
fi.setCurrentPage(0)
fi.invert() #temp fix
thumb = fi.convertToPil()
thumb.thumbnail(THUMBNAIL_SIZE, Image.ANTIALIAS)
thumbs.append((os.path.basename(f), pilToBitmap(thumb)))
thumbs.sort()
return thumbs

Iain

p.s. thanks again
 
M

Michele Petrazzo

Iain said:
I got the TortoiseSVN client though, and
checked out your newest build, copied it over the top of
site-packages/freeimagepy, updated my ctypes back to 0.9.9.6 (I'd
regressed again), ran my program, and it worked. Thanks!

This is a good news!
Next question (and what I'm using FreeImagePy for): I'm loading a pile
of TIF's as thumbnails into a wx list control. I load the image with
FIPY, convert it to PIL, use PIL's antialiasing thumbnail function,
then load it from there into wx.

Why use PIL for it and not FIPY directly? You can use the image.size or
the other methods for resize the image
However, when I'm do the
fipy.convertToPil(), it inverts the image?

No, it not invert the image... It only return the image as is.
I've inserted a
fipy.invert() before the conversion as a temporary fix, but is there a
reason for this?

If you are have a min-is-white image (fax ?) that isn't the standard,
you will have an "inverted" image, because PIl expect a min-is-black
image!
relevant code:

def getHeaders(files):
thumbs = []
for f in files:
print "Adding %s" % f
fi = FIPY.Image(f)
fi.setCurrentPage(0)
fi.invert() #temp fix
thumb = fi.convertToPil()
thumb.thumbnail(THUMBNAIL_SIZE, Image.ANTIALIAS)
thumbs.append((os.path.basename(f), pilToBitmap(thumb)))
thumbs.sort()
return thumbs

Just a question, why "thumbs.sort" ? Inside this list you have only
images!

P.s. you can use also fi.currentPage = 0 rather then
fi.setCurrentPage(0). Is think it look like better :)
Iain

p.s. thanks again

:)

Michele
 
I

Iain King

Michele said:
No, it not invert the image... It only return the image as is.


If you are have a min-is-white image (fax ?) that isn't the standard,
you will have an "inverted" image, because PIl expect a min-is-black
image!


This is probably what is happening. I'll upload one of the images
tomorrow, and you can check it out to make sure.

relevant code:

def getHeaders(files):
thumbs = []
for f in files:
print "Adding %s" % f
fi = FIPY.Image(f)
fi.setCurrentPage(0)
fi.invert() #temp fix
thumb = fi.convertToPil()
thumb.thumbnail(THUMBNAIL_SIZE, Image.ANTIALIAS)
thumbs.append((os.path.basename(f), pilToBitmap(thumb)))
thumbs.sort()
return thumbs

Just a question, why "thumbs.sort" ? Inside this list you have only
images!

Ah, look closer! It's a list of tuples: (filename, image)
I'll try out FIPY's resizing tomorrow too. OTOH, I have functions to
convert between PIL and wxPython, and functions to convert betweem PIL
and FIPY, but I don't see a function to convert FIPY to wxPython?

Iain
 
I

Iain King

Iain said:
Michele said:
No, it not invert the image... It only return the image as is.


If you are have a min-is-white image (fax ?) that isn't the standard,
you will have an "inverted" image, because PIl expect a min-is-black
image!


This is probably what is happening. I'll upload one of the images
tomorrow, and you can check it out to make sure.

relevant code:

def getHeaders(files):
thumbs = []
for f in files:
print "Adding %s" % f
fi = FIPY.Image(f)
fi.setCurrentPage(0)
fi.invert() #temp fix
thumb = fi.convertToPil()
thumb.thumbnail(THUMBNAIL_SIZE, Image.ANTIALIAS)
thumbs.append((os.path.basename(f), pilToBitmap(thumb)))
thumbs.sort()
return thumbs

Just a question, why "thumbs.sort" ? Inside this list you have only
images!

Ah, look closer! It's a list of tuples: (filename, image)
I'll try out FIPY's resizing tomorrow too. OTOH, I have functions to
convert between PIL and wxPython, and functions to convert betweem PIL
and FIPY, but I don't see a function to convert FIPY to wxPython?

Image at: http://www.snakebomb.com/misc/example.tif

Iain
 
M

Michele Petrazzo

Iain said:

Yes it's min-is-white::

michele:~$ tiffinfo example.tif
TIFFReadDirectory: Warning, example.tif: unknown field with tag 37680
(0x9330) encountered.
TIFF Directory at offset 0x1520 (5408)
Subfile Type: (0 = 0x0)
Image Width: 1696 Image Length: 1162
Resolution: 200, 200 pixels/inch
Bits/Sample: 1
Compression Scheme: CCITT Group 4
Photometric Interpretation: min-is-white # <------
FillOrder: msb-to-lsb
Samples/Pixel: 1
Rows/Strip: 1162
Planar Configuration: single image plane
ImageDescription: DS
michele:~$

So you *need* to invert it to work correctly with PIL!

P.s. Added the convertToWx function, that return a wx.Image, to the
Image class.

Michele
 
I

Iain King

Michele said:
Yes it's min-is-white::

michele:~$ tiffinfo example.tif
TIFFReadDirectory: Warning, example.tif: unknown field with tag 37680
(0x9330) encountered.
TIFF Directory at offset 0x1520 (5408)
Subfile Type: (0 = 0x0)
Image Width: 1696 Image Length: 1162
Resolution: 200, 200 pixels/inch
Bits/Sample: 1
Compression Scheme: CCITT Group 4
Photometric Interpretation: min-is-white # <------
FillOrder: msb-to-lsb
Samples/Pixel: 1
Rows/Strip: 1162
Planar Configuration: single image plane
ImageDescription: DS
michele:~$

So you *need* to invert it to work correctly with PIL!

P.s. Added the convertToWx function, that return a wx.Image, to the
Image class.

Michele

Most excellent!

Iain
 
F

Fredrik Lundh

Michele said:
Yes it's min-is-white::

michele:~$ tiffinfo example.tif
TIFFReadDirectory: Warning, example.tif: unknown field with tag 37680
(0x9330) encountered.
TIFF Directory at offset 0x1520 (5408)
Subfile Type: (0 = 0x0)
Image Width: 1696 Image Length: 1162
Resolution: 200, 200 pixels/inch
Bits/Sample: 1
Compression Scheme: CCITT Group 4
Photometric Interpretation: min-is-white # <------
FillOrder: msb-to-lsb
Samples/Pixel: 1
Rows/Strip: 1162
Planar Configuration: single image plane
ImageDescription: DS
michele:~$

So you *need* to invert it to work correctly with PIL!

PIL has no problem reading "min-is-white" TIFF images.

it would be nice if you stopped posting bogus "support" information for
other libraries.

</F>
 
M

Michele Petrazzo

Fredrik said:
PIL has no problem reading "min-is-white" TIFF images.

it would be nice if you stopped posting bogus "support" information
for other libraries.

Sorry if my posts make to seem that other libraries has problems! Sure
that *my* wrap has problems, like I have problem with something that I
don't know so well, like Image world (like I always said). I'm only
suggesting some, bad, trick for do the work that "Iain" wants.
I tried, but without success, to make the "convertToPil" function work
with 1, 8, 16 bpp... Seem that only 24/32 work, but I don't know why.

I know that PIL doesn't have problems!

Hope that this can explain better the situation.

Bye,
Michele
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top