Trying to get FreeImagePy to work.

Discussion in 'Python' started by Iain King, May 26, 2006.

  1. Iain King

    Iain King Guest

    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
    Iain King, May 26, 2006
    #1
    1. Advertising

  2. 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
    Michele Petrazzo, May 26, 2006
    #2
    1. Advertising

  3. Iain King

    Iain King Guest

    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
    Iain King, May 26, 2006
    #3
  4. 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
    Michele Petrazzo, May 26, 2006
    #4
  5. Iain King

    Iain King Guest

    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
    Iain King, Jun 1, 2006
    #5
  6. 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
    Michele Petrazzo, Jun 1, 2006
    #6
  7. Iain King

    Iain King Guest

    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
    Iain King, Jun 1, 2006
    #7
  8. 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
    Michele Petrazzo, Jun 1, 2006
    #8
  9. Iain King

    Iain King Guest

    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
    Iain King, Jun 1, 2006
    #9
  10. Iain King

    Iain King Guest

    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
    Iain King, Jun 2, 2006
    #10
  11. 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
    Michele Petrazzo, Jun 3, 2006
    #11
  12. Iain King

    Iain King Guest

    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
    Iain King, Jun 5, 2006
    #12
  13. 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>
    Fredrik Lundh, Jun 5, 2006
    #13
  14. 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
    Michele Petrazzo, Jun 5, 2006
    #14
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michele Petrazzo

    [ANN] FreeImagePy 1.0.0

    Michele Petrazzo, Aug 31, 2005, in forum: Python
    Replies:
    0
    Views:
    292
    Michele Petrazzo
    Aug 31, 2005
  2. Michele Petrazzo

    ANN: FreeImagePy 1.2.0

    Michele Petrazzo, Jan 20, 2006, in forum: Python
    Replies:
    0
    Views:
    262
    Michele Petrazzo
    Jan 20, 2006
  3. Michele Petrazzo

    ANN: FreeImagePy 1.2.2

    Michele Petrazzo, Feb 16, 2006, in forum: Python
    Replies:
    7
    Views:
    433
    Terry Hancock
    Feb 19, 2006
  4. David Isaac

    FreeImagePy and PIL

    David Isaac, Jun 4, 2006, in forum: Python
    Replies:
    1
    Views:
    313
    Michele Petrazzo
    Jun 5, 2006
  5. Replies:
    1
    Views:
    764
    Michele Petrazzo
    Oct 31, 2006
Loading...

Share This Page