Trying to get FreeImagePy to work.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Iain King

    #1

    Trying to get FreeImagePy to work.

    I've installed ctypes and FreeImagePy. When I do this:
    [color=blue][color=green][color=darkred]
    >>> import FreeImagePy
    >>> f = FreeImagePy.Ima ge()[/color][/color][/color]

    I get:
    find
    Traceback (most recent call last):
    File "<stdin>", line 1, in ?
    File "C:\Python\Lib\ site-packages\FreeIm agePy\FreeImage Py.py", line
    1952, in _
    _init__
    super(Image, self).__init__( libraryName)
    File "C:\Python\Lib\ site-packages\FreeIm agePy\FreeImage Py.py", line
    376, in __
    init__
    self.__lib = self.__internlL ibrary(libraryN ame)
    File "C:\Python\Lib\ site-packages\FreeIm agePy\FreeImage Py.py", line
    313, in __
    init__
    self.lib = C.windll.find(l ibraryName)
    File "ctypes\__init_ _.py", line 370, in __getattr__
    dll = self._dlltype(n ame)
    File "ctypes\__init_ _.py", line 296, in __init__
    self._handle = _dlopen(self._n ame, 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

  • Michele Petrazzo

    #2
    Re: Trying to get FreeImagePy to work.

    Iain King wrote:[color=blue]
    > I've installed ctypes and FreeImagePy. When I do this:
    >[color=green][color=darkred]
    >>>> import FreeImagePy f = FreeImagePy.Ima ge()[/color][/color]
    >
    > 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?[/color]

    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)
    [color=blue]
    >
    > Iain
    >[/color]

    Bye,
    Michele

    Comment

    • Iain King

      #3
      Re: Trying to get FreeImagePy to work.


      Michele Petrazzo wrote:[color=blue]
      > Iain King wrote:[color=green]
      > > I've installed ctypes and FreeImagePy. When I do this:
      > >[color=darkred]
      > >>>> import FreeImagePy f = FreeImagePy.Ima ge()[/color]
      > >
      > > 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?[/color]
      >
      > 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)
      >[/color]

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

      Iain

      Comment

      • Michele Petrazzo

        #4
        Re: Trying to get FreeImagePy to work.

        Iain King wrote:[color=blue]
        > Michele Petrazzo wrote:
        >
        > I downloaded and installed 0.9.9.3, and it now works. Thanks!
        >[/color]

        I advice you to don't use that ctypes version... Better is to use the
        newest one and update freeimagepy!
        [color=blue]
        > Iain
        >[/color]

        Michele

        Comment

        • Iain King

          #5
          Re: Trying to get FreeImagePy to work.


          Michele Petrazzo wrote:[color=blue]
          > Iain King wrote:[color=green]
          > > Michele Petrazzo wrote:
          > >
          > > I downloaded and installed 0.9.9.3, and it now works. Thanks!
          > >[/color]
          >
          > I advice you to don't use that ctypes version... Better is to use the
          > newest one and update freeimagepy!
          >[color=green]
          > > Iain
          > >[/color]
          >
          > Michele[/color]

          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

          Comment

          • Michele Petrazzo

            #6
            Re: Trying to get FreeImagePy to work.

            Iain King wrote:[color=blue]
            > Michele Petrazzo wrote:[color=green]
            >> Iain King wrote:[color=darkred]
            >>> Michele Petrazzo wrote:
            >>>
            >>> I downloaded and installed 0.9.9.3, and it now works. Thanks!
            >>>[/color]
            >> I advice you to don't use that ctypes version... Better is to use
            >> the newest one and update freeimagepy!
            >>[color=darkred]
            >>> Iain
            >>>[/color]
            >> Michele[/color]
            >
            > 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
            >[/color]

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

            Bye,
            Michele

            Comment

            • Iain King

              #7
              Re: Trying to get FreeImagePy to work.


              Michele Petrazzo wrote:[color=blue]
              > Iain King wrote:[color=green]
              > > Michele Petrazzo wrote:[color=darkred]
              > >> 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[/color]
              > >
              > > 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
              > >[/color]
              >
              > Can you download the last svn version from sf.net? Otherwise I'll send
              > you the last sources privately.
              >
              > Bye,
              > Michele[/color]

              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.convertToP il(), 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(file s):
              thumbs = []
              for f in files:
              print "Adding %s" % f
              fi = FIPY.Image(f)
              fi.setCurrentPa ge(0)
              fi.invert() #temp fix
              thumb = fi.convertToPil ()
              thumb.thumbnail (THUMBNAIL_SIZE , Image.ANTIALIAS )
              thumbs.append(( os.path.basenam e(f), pilToBitmap(thu mb)))
              thumbs.sort()
              return thumbs

              Iain

              p.s. thanks again

              Comment

              • Michele Petrazzo

                #8
                Re: Trying to get FreeImagePy to work.

                Iain King wrote:[color=blue][color=green]
                >> Can you download the last svn version from sf.net? Otherwise I'll send
                >> you the last sources privately.
                >>
                >> Bye,
                >> Michele[/color]
                >[/color]
                [color=blue]
                > 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![/color]

                This is a good news!
                [color=blue]
                > 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.[/color]

                Why use PIL for it and not FIPY directly? You can use the image.size or
                the other methods for resize the image
                [color=blue]
                > However, when I'm do the
                > fipy.convertToP il(), it inverts the image?[/color]

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

                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!
                [color=blue]
                > relevant code:
                >
                > def getHeaders(file s):
                > thumbs = []
                > for f in files:
                > print "Adding %s" % f
                > fi = FIPY.Image(f)
                > fi.setCurrentPa ge(0)
                > fi.invert() #temp fix
                > thumb = fi.convertToPil ()
                > thumb.thumbnail (THUMBNAIL_SIZE , Image.ANTIALIAS )
                > thumbs.append(( os.path.basenam e(f), pilToBitmap(thu mb)))
                > thumbs.sort()
                > return thumbs[/color]

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

                P.s. you can use also fi.currentPage = 0 rather then
                fi.setCurrentPa ge(0). Is think it look like better :)
                [color=blue]
                >
                > Iain
                >
                > p.s. thanks again
                >[/color]

                :)

                Michele

                Comment

                • Iain King

                  #9
                  Re: Trying to get FreeImagePy to work.


                  Michele Petrazzo wrote:[color=blue]
                  > Iain King wrote:[color=green]
                  > > However, when I'm do the
                  > > fipy.convertToP il(), it inverts the image?[/color]
                  >
                  > No, it not invert the image... It only return the image as is.
                  >[color=green]
                  > > I've inserted a
                  > > fipy.invert() before the conversion as a temporary fix, but is there a
                  > > reason for this?[/color]
                  >
                  > 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!
                  >[/color]


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

                  [color=blue][color=green]
                  > > relevant code:
                  > >
                  > > def getHeaders(file s):
                  > > thumbs = []
                  > > for f in files:
                  > > print "Adding %s" % f
                  > > fi = FIPY.Image(f)
                  > > fi.setCurrentPa ge(0)
                  > > fi.invert() #temp fix
                  > > thumb = fi.convertToPil ()
                  > > thumb.thumbnail (THUMBNAIL_SIZE , Image.ANTIALIAS )
                  > > thumbs.append(( os.path.basenam e(f), pilToBitmap(thu mb)))
                  > > thumbs.sort()
                  > > return thumbs[/color]
                  >
                  > Just a question, why "thumbs.sor t" ? Inside this list you have only
                  > images![/color]

                  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

                  Comment

                  • Iain King

                    #10
                    Re: Trying to get FreeImagePy to work.


                    Iain King wrote:[color=blue]
                    > Michele Petrazzo wrote:[color=green]
                    > > Iain King wrote:[color=darkred]
                    > > > However, when I'm do the
                    > > > fipy.convertToP il(), it inverts the image?[/color]
                    > >
                    > > No, it not invert the image... It only return the image as is.
                    > >[color=darkred]
                    > > > I've inserted a
                    > > > fipy.invert() before the conversion as a temporary fix, but is there a
                    > > > reason for this?[/color]
                    > >
                    > > 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!
                    > >[/color]
                    >
                    >
                    > This is probably what is happening. I'll upload one of the images
                    > tomorrow, and you can check it out to make sure.
                    >
                    >[color=green][color=darkred]
                    > > > relevant code:
                    > > >
                    > > > def getHeaders(file s):
                    > > > thumbs = []
                    > > > for f in files:
                    > > > print "Adding %s" % f
                    > > > fi = FIPY.Image(f)
                    > > > fi.setCurrentPa ge(0)
                    > > > fi.invert() #temp fix
                    > > > thumb = fi.convertToPil ()
                    > > > thumb.thumbnail (THUMBNAIL_SIZE , Image.ANTIALIAS )
                    > > > thumbs.append(( os.path.basenam e(f), pilToBitmap(thu mb)))
                    > > > thumbs.sort()
                    > > > return thumbs[/color]
                    > >
                    > > Just a question, why "thumbs.sor t" ? Inside this list you have only
                    > > images![/color]
                    >
                    > 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?
                    >[/color]

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

                    Iain

                    Comment

                    • Michele Petrazzo

                      #11
                      Re: Trying to get FreeImagePy to work.

                      Iain King wrote:[color=blue][color=green]
                      >> 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?
                      >>[/color]
                      >
                      > Image at: http://www.snakebomb.com/misc/example.tif
                      >
                      > Iain
                      >[/color]

                      Yes it's min-is-white::

                      michele:~$ tiffinfo example.tif
                      TIFFReadDirecto ry: 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
                      ImageDescriptio n: 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

                      Comment

                      • Iain King

                        #12
                        Re: Trying to get FreeImagePy to work.


                        Michele Petrazzo wrote:[color=blue]
                        > Iain King wrote:[color=green][color=darkred]
                        > >> 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?
                        > >>[/color]
                        > >
                        > > Image at: http://www.snakebomb.com/misc/example.tif
                        > >
                        > > Iain
                        > >[/color]
                        >
                        > Yes it's min-is-white::
                        >
                        > michele:~$ tiffinfo example.tif
                        > TIFFReadDirecto ry: 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
                        > ImageDescriptio n: 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[/color]

                        Most excellent!

                        Iain

                        Comment

                        • Fredrik Lundh

                          #13
                          Re: Trying to get FreeImagePy to work.

                          Michele Petrazzo wrote:
                          [color=blue]
                          > Yes it's min-is-white::
                          >
                          > michele:~$ tiffinfo example.tif
                          > TIFFReadDirecto ry: 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
                          > ImageDescriptio n: DS
                          > michele:~$
                          >
                          > So you *need* to invert it to work correctly with PIL![/color]

                          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>

                          Comment

                          • Michele Petrazzo

                            #14
                            Re: Trying to get FreeImagePy to work.

                            Fredrik Lundh wrote:
                            [color=blue][color=green]
                            >> So you *need* to invert it to work correctly with PIL![/color]
                            >
                            > PIL has no problem reading "min-is-white" TIFF images.
                            >
                            > it would be nice if you stopped posting bogus "support" information
                            > for other libraries.[/color]

                            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 "convertToP il" 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!
                            [color=blue]
                            >
                            > </F>
                            >[/color]

                            Hope that this can explain better the situation.

                            Bye,
                            Michele

                            Comment

                            Working...