473,387 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Trying to get FreeImagePy to work.

I've installed ctypes and FreeImagePy. When I do this:
import FreeImagePy
f = FreeImagePy.Image()


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

May 26 '06 #1
13 1909
Iain King wrote:
I've installed ctypes and FreeImagePy. When I do this:
import FreeImagePy f = FreeImagePy.Image()

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)

Iain


Bye,
Michele
May 26 '06 #2

Michele Petrazzo wrote:
Iain King wrote:
I've installed ctypes and FreeImagePy. When I do this:
> import FreeImagePy f = FreeImagePy.Image()


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)


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

Iain

May 26 '06 #3
Iain King wrote:
Michele Petrazzo wrote:

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

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


Michele
May 26 '06 #4

Michele Petrazzo wrote:
Iain King wrote:
Michele Petrazzo wrote:

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


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


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

Jun 1 '06 #5
Iain King wrote:
Michele Petrazzo wrote:
Iain King wrote:
Michele Petrazzo wrote:

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

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

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


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

Bye,
Michele
Jun 1 '06 #6

Michele Petrazzo wrote:
Iain King wrote:
Michele Petrazzo wrote:
Iain King wrote:
Michele Petrazzo wrote:

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

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

Iain

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


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

Jun 1 '06 #7
Iain King wrote:
Can you download the last svn version from sf.net? Otherwise I'll send
you the last sources privately.

Bye,
Michele

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
Jun 1 '06 #8

Michele Petrazzo wrote:
Iain King wrote:
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!

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

Jun 1 '06 #9

Iain King wrote:
Michele Petrazzo wrote:
Iain King wrote:
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!

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

Jun 2 '06 #10
Iain King wrote:
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


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
Jun 3 '06 #11

Michele Petrazzo wrote:
Iain King wrote:
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


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

Jun 5 '06 #12
Michele Petrazzo wrote:
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>

Jun 5 '06 #13
Fredrik Lundh wrote:
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.


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!

</F>


Hope that this can explain better the situation.

Bye,
Michele
Jun 5 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Marcus | last post by:
I am trying to auto-detect what folder a file is sitting in and based upon this info, query a MySQL database to get further information. I have been all over php.net and been through numerous...
5
by: Patrice FRITSCH | last post by:
I'm trying to run a batch file from an asp page using WScript.Shell object. Dim oWSH set oWSH= Server.CreateObject("WScript.Shell") call oWSH.Run("cmd.exe /c " & szCmd , 0, true) szCmd...
1
by: Larry | last post by:
I am a C++/Java programmer trying to get going with some simpe xml transformations at work here. I bought the O'Reilly book Learning xlst for kicks. Someone at work sent me this xml shown below,...
16
by: Andrew Baker | last post by:
I am trying to write a function which provides my users with a file filter. The filter used to work just using the VB "Like" comparision, but I can't find the equivilant in C#. I looked at...
6
by: Frank Wilson | last post by:
Tom, It sounds to me like ASP, not ASP.NET is handling the request for WebForm1.aspx. This is most likely an IIS config issue that may have been caused by order of installation or...
6
by: Larry Woods | last post by:
I am trying to name my submenus (MainMenu control) and they show up in the menu dropdown...like they are O.K., but when I check my controls the names are still "MenuItemX". OTOH, the top-level...
1
by: David Isaac | last post by:
I am just starting to think about image processing. What are the overlaps and differences in intended functionality between FreeImagePy and PIL? Thanks, Alan Isaac
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
5
by: Pauley | last post by:
Hello, Please keep in mind when you read this post that I am a total noob when it comes to coding. Coding in ASP On MS Server SQL Database/Table I know this topic has been covered many...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.