Uncompressing TIFF files directly in Python

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

    #1

    Uncompressing TIFF files directly in Python

    Hey guys,

    OK this is a long shot but does anyone know of a way to uncompress tiff
    files directly in python. I know it can be done with an os call but
    that'll only work on unix and only if the right software is installed!

    I need to convert tiff images downloaded from uspto.gov to pdf, these
    images are compressed using G4, so I dunno if anyone knows of a method
    of doing this witout the os call! Surely there is a utility out there
    somewhere?

    Sophie

  • Peter Hansen

    #2
    Re: Uncompressing TIFF files directly in Python

    sophie_newbie wrote:[color=blue]
    > Hey guys,
    >
    > OK this is a long shot but does anyone know of a way to uncompress tiff
    > files directly in python. I know it can be done with an os call but
    > that'll only work on unix and only if the right software is installed!
    >
    > I need to convert tiff images downloaded from uspto.gov to pdf, these
    > images are compressed using G4, so I dunno if anyone knows of a method
    > of doing this witout the os call! Surely there is a utility out there
    > somewhere?[/color]

    Why didn't you want an OS call? Do you have other constraints that
    would invalidate anything but a pure Python solution?

    What about using FreeImage? (http://freeimage.sourceforge.net)

    It can be called via ctypes as http://freeimagepy.sourceforge.net/ does.

    -Peter

    Comment

    • Paul Rubin

      #3
      Re: Uncompressing TIFF files directly in Python

      "sophie_new bie" <paulgeeleher@g mail.com> writes:[color=blue]
      > I need to convert tiff images downloaded from uspto.gov to pdf, these
      > images are compressed using G4, so I dunno if anyone knows of a method
      > of doing this witout the os call! Surely there is a utility out there
      > somewhere?[/color]

      There's a libtiff library callable from C. Maybe someone has written
      Python wrappers for it; if not, maybe you can become that someone.

      Comment

      • sophie_newbie

        #4
        Re: Uncompressing TIFF files directly in Python

        I mainly just need it to work with windows and assumed that an os call
        would only work with windows!

        I've downloaded that free image software and the ctypes program, it
        seems to be working but I haven't yet worked out how to get it to
        decompress a G4 TIFF image...

        If anyone knows it would be of help?

        Comment

        • Fredrik Lundh

          #5
          Re: Uncompressing TIFF files directly in Python

          "sophie_new bie" wrote:
          [color=blue]
          > I mainly just need it to work with windows and assumed that an os call
          > would only work with windows!
          >
          > I've downloaded that free image software and the ctypes program, it
          > seems to be working but I haven't yet worked out how to get it to
          > decompress a G4 TIFF image...
          >
          > If anyone knows it would be of help?[/color]

          tiffcp and friends are available for windows too:



          infile = "somefile.t if"

          os.system("tiff cp -c none %s temp.tif" % infile)

          im = Image.open("tem p.tif")

          </F>



          Comment

          • Peter Hansen

            #6
            Re: Uncompressing TIFF files directly in Python

            sophie_newbie wrote:[color=blue]
            > I mainly just need it to work with windows and assumed that an os call
            > would only work with windows![/color]

            Presumably you mistyped something there, since what you are basically
            saying is that an os call which only works on windows would suit you
            just fine since you only care about windows.

            -Peter

            Comment

            • Gary Duzan

              #7
              Re: Uncompressing TIFF files directly in Python

              sophie_newbie wrote:[color=blue]
              > Hey guys,
              >
              > OK this is a long shot but does anyone know of a way to uncompress tiff
              > files directly in python. I know it can be done with an os call but
              > that'll only work on unix and only if the right software is installed!
              >
              > I need to convert tiff images downloaded from uspto.gov to pdf, these
              > images are compressed using G4, so I dunno if anyone knows of a method
              > of doing this witout the os call! Surely there is a utility out there
              > somewhere?[/color]

              You can look into using the Python Imaging Library, which supports
              reading TIFFs and runs on multiple platforms, including Windows.

              http://www.pythonware.com/products/pil/

              Gary Duzan
              Motorola CHS

              Comment

              • sophie_newbie

                #8
                Re: Uncompressing TIFF files directly in Python

                Ya I did, sorry!

                Comment

                • sophie_newbie

                  #9
                  Re: Uncompressing TIFF files directly in Python

                  Ya that was the original plan but it didn't support the G4 compression
                  of the tif files!

                  I think the idea of using tiffcp is the best as it runs on both unix
                  and windows which is what i need!

                  Comment

                  Working...