Giter Club home page Giter Club logo

pylibtiff's Introduction

Build Status

PyLibTiff is a package that provides:

  • a wrapper to the libtiff library to Python using ctypes.

  • a pure Python module for reading and writing TIFF and LSM files. The images are read as numpy.memmap objects so that it is possible to open images that otherwise would not fit to computers RAM. Both TIFF strips and tiles are supported for low-level data storage.

There exists many Python packages such as PIL, FreeImagePy that support reading and writing TIFF files. The PyLibTiff project was started to have an efficient and direct way to read and write TIFF files using the libtiff library without the need to install any unnecessary packages or libraries. The pure Python module was created for reading "broken" TIFF files such as LSM files that in some places use different interpretation of TIFF tags than what specified in the TIFF specification document. The libtiff library would just fail reading such files. In addition, the pure Python module is more memory efficient as the arrays are returned as memory maps. Support for compressed files is not implemented yet.

tifffile.py by Christoph Gohlke is an excellent module for reading TIFF as well as LSM files, it is as fast as libtiff.py by using numpy.

Usage example (libtiff wrapper)

>>> from libtiff import TIFF
>>> # to open a tiff file for reading:
>>> tif = TIFF.open('filename.tif', mode='r')
>>> # to read an image in the currect TIFF directory and return it as numpy array:
>>> image = tif.read_image()
>>> # to read all images in a TIFF file:
>>> for image in tif.iter_images(): # do stuff with image
>>> # to open a tiff file for writing:
>>> tif = TIFF.open('filename.tif', mode='w')
>>> # to write a image to tiff file
>>> tif.write_image(image)

Usage example (pure Python module)

>>> from libtiff import TIFFfile, TIFFimage
>>> # to open a tiff file for reading
>>> tif = TIFFfile('filename.tif')
>>> # to return memmaps of images and sample names (eg channel names, SamplesPerPixel>=1)
>>> samples, sample_names = tiff.get_samples()
>>> # to create a tiff structure from image data
>>> tiff = TIFFimage(data, description='')
>>> # to write tiff structure to file
>>> tiff.write_file('filename.tif', compression='none') # or 'lzw'
>>> del tiff # flushes data to disk

Script usage examples

$ libtiff.info -i result_0.tif
IFDEntry(tag=ImageWidth, value=512, count=1, offset=None)
IFDEntry(tag=ImageLength, value=512, count=1, offset=None)
IFDEntry(tag=BitsPerSample, value=32, count=1, offset=None)
IFDEntry(tag=Compression, value=1, count=1, offset=None)
IFDEntry(tag=PhotometricInterpretation, value=1, count=1, offset=None)
IFDEntry(tag=StripOffsets, value=8, count=1, offset=None)
IFDEntry(tag=Orientation, value=6, count=1, offset=None)
IFDEntry(tag=StripByteCounts, value=1048576, count=1, offset=None)
IFDEntry(tag=PlanarConfiguration, value=1, count=1, offset=None)
IFDEntry(tag=SampleFormat, value=3, count=1, offset=None)
Use --ifd to see the rest of 31 IFD entries
data is contiguous: False
memory usage is ok: True
sample data shapes and names:

width : 512
length : 512
samples_per_pixel : 1
planar_config : 1
bits_per_sample : 32
strip_length : 1048576

[('memmap', (32, 512, 512), dtype('float32'))] ['sample0']
$ libtiff.info -i psf_1024_z5_airy1_set1.lsm
IFDEntry(tag=NewSubfileType, value=0, count=1, offset=None)
IFDEntry(tag=ImageWidth, value=1024, count=1, offset=None)
IFDEntry(tag=ImageLength, value=1024, count=1, offset=None)
IFDEntry(tag=BitsPerSample, value=8, count=1, offset=None)
IFDEntry(tag=Compression, value=1, count=1, offset=None)
IFDEntry(tag=PhotometricInterpretation, value=1, count=1, offset=None)
IFDEntry(tag=StripOffsets, value=97770, count=1, offset=None)
IFDEntry(tag=SamplesPerPixel, value=1, count=1, offset=None)
IFDEntry(tag=StripByteCounts, value=1048576, count=1, offset=None)
IFDEntry(tag=PlanarConfiguration, value=2, count=1, offset=None)
IFDEntry(tag=CZ_LSMInfo, value=CZ_LSMInfo276(
  MagicNumber=[67127628], 
  StructureSize=[500], 
  DimensionX=[1024], 
  DimensionY=[1024], 
  DimensionZ=[20], 
  DimensionChannels=[1], 
  DimensionTime=[1], 
  SDataType=[1], 
  ThumbnailX=[128], 
  ThumbnailY=[128], 
  VoxelSizeX=[  2.79017865e-08], 
  VoxelSizeY=[  2.79017865e-08], 
  VoxelSizeZ=[  3.60105263e-07], 
  OriginX=[ -2.22222228e-07], 
  OriginY=[  1.90476196e-07], 
  OriginZ=[ 0.], 
  ScanType=[0], 
  SpectralScan=[0], 
  DataType=[0], 
  OffsetVectorOverlay->DrawingElement(name='OffsetVectorOverlay', size=200, offset=6560), 
  OffsetInputLut->LookupTable(name='OffsetInputLut', size=8388, subblocks=6, channels=1, offset=7560), 
  OffsetOutputLut->LookupTable(name='OffsetOutputLut', size=24836, subblocks=3, channels=3, offset=15948), 
  OffsetChannelColors->ChannelColors (names=['Ch3'], colors=[(255, 0, 0, 0)]), 
  TimeInterval=[ 0.], 
  OffsetChannelDataTypes->None, 
  OffsetScanInformation->recording[size=3535]
   name = 'psf_1024_z5_airy1_set1'
   description = ' '
   notes = ' '
   objective = 'C-Apochromat 63x/1.20 W Korr UV-VIS-IR M27'
   special scan mode = 'FocusStep'
   scan type = ''
   scan mode = 'Stack'
   number of stacks = 10
   lines per plane = 1024
   samples per line = 1024
   planes per volume = 20
   images width = 1024
   images height = 1024
   images number planes = 20
   images number stacks = 1
   images number channels = 1
   linescan xy size = 512
   scan direction = 0
   scan directionz = 0
   time series = 0
   original scan data = 1
   zoom x = 5.0000000000000009
   zoom y = 5.0000000000000009
   zoom z = 1.0
   sample 0x = -0.22200000000000006
   sample 0y = 0.19000000000000006
   sample 0z = 6.8420000000000014
   sample spacing = 0.028000000000000008
   line spacing = 0.028000000000000008
   plane spacing = 0.3600000000000001
   rotation = 0.0
   nutation = 0.0
   precession = 0.0
   sample 0time = 39583.598368055624
   start scan trigger in = ''
   start scan trigger out = ''
   start scan event = 0
   start scan time = 0.0
   stop scan trigger in = ''
   stop scan trigger out = ''
   stop scan event = 0
   start scan time = 0.0
   use rois = 0
   use reduced memory rois = 0
   user = 'User Name'
   usebccorrection = 0
   positionbccorrection1 = 0.0
   positionbccorrection2 = 0.0
   interpolationy = 1
   camera binning = 1
   camera supersampling = 0
   camera frame width = 1388
   camera frame height = 1040
   camera offsetx = 0.0
   camera offsety = 0.0
   rt binning = 1
  ENTRY0x10000064L = 1
   rt frame width = 512
   rt frame height = 512
   rt region width = 512
   rt region height = 512
   rt offsetx = 0.0
   rt offsety = 0.0
   rt zoom = 1.0000000000000004
   rt lineperiod = 112.43300000000002
   prescan = 0
  lasers[size=188]
    laser[size=80]
       name = 'HeNe633'
       acquire = 1
       power = 5.0000000000000009
    end laser
    laser[size=84]
       name = 'DPSS 532-75'
       acquire = 1
       power = 75.000000000000014
    end laser
  end lasers
  tracks[size=2071]
    track[size=2047]
       pixel time = 1.5980000000000003
       time between stacks = 1.0
       multiplex type = 1
       multiplex order = 1
       sampling mode = 2
       sampling method = 1
       sampling number = 8
       acquire = 1
       name = 'Track'
       collimator1 position = 16
       collimator1 name = 'IR/Vis'
       collimator2 position = 66
       collimator2 name = 'UV/Vis'
       is bleach track = 0
       is bleach after scan number = 0
       bleach scan number = 0
       trigger in = ''
       trigger out = ''
       is ratio track = 0
       bleach count = 0
       spi center wavelength = 582.53000000000009
       id condensor aperture = 'KAB1'
       condensor aperture = 0.55000000000000016
       id condensor revolver = 'FW2'
       condensor filter = 'HF'
       id tubelens = 'Tubelens'
       id tubelens position = 'Lens LSM'
       transmitted light = 0.0
       reflected light = -1.0000000000000002
      detection channels[size=695]
        detection channel[size=671]
           detector gain first = 700.00000000000011
           detector gain last = 700.00000000000011
           amplifier gain first = 1.0000000000000002
           amplifier gain last = 1.0000000000000002
           amplifier offs first = 0.10000000000000002
           amplifier offs last = 0.10000000000000002
           pinhole diameter = 144.00000000000003
           counting trigger = 5.0
           acquire = 1
           integration mode = 0
           special mode = 0
           detector name = 'Pmt3'
           amplifier name = 'Amplifier1'
           pinhole name = 'PH3'
           filter set name = 'EF3'
           filter name = 'LP 650'
          ENTRY0x70000011L = ''
          ENTRY0x70000012L = ''
           integrator name = 'Integrator3'
           detection channel name = 'Ch3'
           detector gain bc1 = 0.0
           detector gain bc2 = 0.0
           amplifier gain bc1 = 0.0
           amplifier gain bc2 = 0.0
           amplifier offs bc1 = 0.0
           amplifier offs bc2 = 0.0
           spectral scan channels = 32
           spi wavelength start = 415.0
           spi wavelength end = 735.0
          ENTRY0x70000024L = 575.0
          ENTRY0x70000025L = 575.0
           dye name = ''
           dye folder = ''
          ENTRY0x70000028L = 1.0000000000000004
          ENTRY0x70000029L = 0.0
        end detection channel
      end detection channels
      beam splitters[size=330]
        beam splitter[size=82]
           filter set = 'HT'
           filter = 'HFT 405/514/633'
           name = 'HT'
        end beam splitter
        beam splitter[size=75]
           filter set = 'NT1'
           filter = 'Mirror'
           name = 'NT1'
        end beam splitter
        beam splitter[size=76]
           filter set = 'NT2'
           filter = 'NFT 565'
           name = 'NT2'
        end beam splitter
        beam splitter[size=73]
           filter set = 'FW1'
           filter = 'None'
           name = 'FW1'
        end beam splitter
      end beam splitters
      illumination channels[size=160]
        illumination channel[size=136]
           name = '633'
           power = 0.30000000000000004
           wavelength = 633.0
           aquire = 1
           power bc1 = 0.0
           power bc2 = 0.0
        end illumination channel
      end illumination channels
      data channels[size=338]
        data channel[size=314]
           name = 'Ch3'
           acquire = 1
           acquire = 0
           color = 255
           sampletype = 1
           bitspersample = 8
           ratio type = 0
           ratio track1 = 0
           ratio track2 = 0
           ratio channel1 = ''
           ratio channel2 = ''
           ratio const1 = 0.0
           ratio const2 = 0.0
           ratio const3 = 1.0
           ratio const4 = 0.0
           ratio const5 = 0.0
           ratio const6 = 0.0
        end data channel
      end data channels
    end track
  end tracks
  timers[size=24]
  end timers
  markers[size=24]
  end markers
end recording, 
  OffsetKsData->OffsetData(name='OffsetKsData', size=8, offset=48590), 
  OffsetTimeStamps->TimeStamps(stamps=[ 2335.75582836]), 
  OffsetEventList->EventList(events=[]), 
  OffsetRoi->DrawingElement(name='OffsetRoi', size=200, offset=6160), 
  OffsetBleachRoi->DrawingElement(name='OffsetBleachRoi', size=200, offset=6360), 
  OffsetNextRecording->None, 
  DisplayAspectX=[ 1.], 
  DisplayAspectY=[ 1.], 
  DisplayAspectZ=[ 1.], 
  DisplayAspectTime=[ 1.], 
  OffsetMeanOfRoisOverlay->DrawingElement(name='OffsetMeanOfRoisOverlay', size=200, offset=6760), 
  OffsetTopoIsolineOverlay->DrawingElement(name='OffsetTopoIsolineOverlay', size=200, offset=7160), 
  OffsetTopoProfileOverlay->DrawingElement(name='OffsetTopoProfileOverlay', size=200, offset=7360), 
  OffsetLinescanOverlay->DrawingElement(name='OffsetLinescanOverlay', size=200, offset=6960), 
  ToolbarFlags=[0], 
  OffsetChannelWavelength->ChannelWavelength (ranges=[(-1.0, -1.0)]), 
  OffsetChannelFactors->ChannelFactors(size=36, offset=40836), 
  ObjectiveSphereCorrection=[ 0.], 
  OffsetUnmixParameters->OffsetData(name='OffsetUnmixParameters', size=124, offset=48466), 
  Reserved=[[40896 44726     0     0     0     0     0     0     0     0     0     0
      0     0     0     0     0     0     0     0     0     0     0     0
      0     0     0     0     0     0     0     0     0     0     0     0
      0     0     0     0     0     0     0     0     0     0     0     0
      0     0     0     0     0     0     0     0     0     0     0     0
      0     0     0     0     0     0     0     0     0]]))
Use --ifd to see the rest of 39 IFD entries
data is contiguous: False
memory usage is ok: True
sample data shapes and names:

width : 1024
length : 1024
samples_per_pixel : 1
planar_config : 2
bits_per_sample : 8
strip_length : 1048576

[('memmap', (20, 1024, 1024), dtype('uint8'))] ['Ch3']
[((20, 128, 128), dtype('uint8')), ((20, 128, 128), dtype('uint8')), ((20, 128, 128), dtype('uint8'))] ['red', 'green', 'blue']

pylibtiff's People

Contributors

avalentino avatar bgruening avatar cgohlke avatar dennis-johnson avatar dependabot[bot] avatar dirkboye avatar djhoese avatar geekofhearts avatar idristhedragon avatar jakirkham avatar jat255 avatar joostvanpinxten avatar manthey avatar moi90 avatar oleksandr-pavlyk avatar one-sixth avatar ossdev07 avatar pearu avatar pieleric avatar richcarni avatar robert-ancell avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pylibtiff's Issues

Enhance parsing of tiff.h

I had patched r87 myself when I got a new libtiff on fedora 18.  Hadn't got 
around to submitting the patch though.  I noticed it got fixed in svn but 
thought I'd add a minor detail.

In the svn version exceptions are raised when header refers to values already 
defined instead of using numbers.  Adding the value dict back to the eval 
statement allows those to be parsed and added to the value instead of raising.  
Also using re makes a few less lines of code needed to get the right values 
into the words.

Not a big deal.. just thought I'd submit anyway.

Index: libtiff/libtiff_ctypes.py
===================================================================
--- libtiff/libtiff_ctypes.py   (revision 93)
+++ libtiff/libtiff_ctypes.py   (working copy)
@@ -13,6 +13,7 @@
 __all__ = ['libtiff', 'TIFF']

 import os
+import re
 import sys
 import numpy as np
 from numpy import ctypeslib
@@ -71,10 +72,7 @@
     d = {}
     for line in f.readlines():
         if not line.startswith('#define'): continue
-        words = line[7:].lstrip().split()
-        if len(words)>2:
-            words[1] = ''.join(words[1:])
-            del words[2:]
+        words = re.split( "\s*", line[7:].strip(), 1 )
         if len (words)!=2: continue
         name, value = words
         i = value.find('/*')
@@ -82,11 +80,7 @@
         if value in d:
             value = d[value]
         else:
-            try:
-                value = eval(value)
-            except:
-                print `value, line`
-                raise
+            value = eval(value,d)
         d[name] = value
         l.append('%s = %s' % (name, value))
     f.close()

Original issue reported on code.google.com by [email protected] on 14 Jun 2013 at 4:40

photometric interpretation = 2 but only 2 samples per pixel

I have an LSM file with a photometric_interpretation of 2 (RGB) but only 2 samples per pixel (because I acquired 2 channels). As a consequence I can't load the file, because it fails at the assertion statement at line 501 in tiff_file.get_samples()

I wonder what is the best way to proceed to get the file to load?

TIFF.read_image() fails to read RGB images

TIFF.read_image() only works with grey-scale images. When attempting to read a 
RGB image, it only returns the R channel (in separate plane config) or the  
first third of the data (in contiguous plane config).

The SamplesPerPixel field must be taken into account, and if it's more than 1, 
the returned array must be a 3D array.

This is what the attached patch does. It handles both contiguous and separate 
plane configs. 

The patch is also available as a git commit here:
https://github.com/delmic/pylibtiff/commit/94eabe3b063d1d245d46c67adbe91604b944b
a0e

Original issue reported on code.google.com by [email protected] on 5 Aug 2013 at 2:17

Attachments:

http://openjpeg.googlecode.com/svn/dev-utils/scripts/generate_big_files.sh

Please add support for the new libtiff 4.0.1 which adds BigTiff support.

Issues is:


>>> import libtiff
Generating '/usr/lib/python2.7/dist-packages/libtiff/tiff_h_4_0_1.py'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/libtiff/__init__.py", line 20, in <module>
    from .libtiff_ctypes import libtiff, TIFF
  File "/usr/lib/python2.7/dist-packages/libtiff/libtiff_ctypes.py", line 87, in <module>
    f = open(fn, 'w')
IOError: [Errno 13] Permission denied: 
'/usr/lib/python2.7/dist-packages/libtiff/tiff_h_4_0_1.py'
>>> 


Thanks

Original issue reported on code.google.com by mathieu.malaterre on 11 Mar 2012 at 4:40

libtiff 4.x and custom tags

What steps will reproduce the problem?
1. Add custom tags of specific data type using the "add_tags" function in 
libtiff_ctypes.py
2. Read or write file with these custom tags.
3. Get segmentation fault or assert(0)

What is the expected output? What do you see instead?
With libtiff 3.9 there are no segmentation faults or assertion errors or other 
crashes.

Please use labels and text to provide additional information.
I originally added the custom tag functionality to libtiff_ctypes.py. I was 
updating some of my environments that use pylibtiff with libtiff 4.0.3 and 
found that the tests at the bottom of libtiff_ctypes cause a segmentation fault 
that seems to be linked to the custom tag test. Also, when using custom tags 
there seems to be certain types that aren't supported in the new libtiff layout 
which results in an assert(0) error. One specific example is a tag with type 
"TIFF_SLONG" will be assigned an internal type of "TIFF_SETGET_SINT32", but the 
code to handle this type does not exist later in the library calls.

I think the "correct" decision is to update libtiff_ctypes to check the version 
of libtiff used and if 4.0+ use the new functions for adding custom tags. The 
problem with that is I don't think there is any documentation for creating 
custom tags in 4.0. I've asked the libtiff mailing list for any advice and I'll 
go from there.

Original issue reported on code.google.com by [email protected] on 17 Feb 2015 at 4:10

Failure to generate tiff_h_4_0_8

For some reason, pylibtiff fails to generate tiff_h_4_0_8. For example, when using iocbio:

Python 2.7.12 (default, Jan  5 2017, 09:19:29) 
[GCC 4.9.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import iocbio.io
unexpected EOF while parsing (<string>, line 1): '(1'
unexpected EOF while parsing (<string>, line 1): '(1'
unexpected EOF while parsing (<string>, line 1): '(1'
unexpected EOF while parsing (<string>, line 1): '(1'
unexpected EOF while parsing (<string>, line 1): '(1'
unexpected EOF while parsing (<string>, line 1): '(1'
Generating '/usr/local/lib/python2.7/site-packages/iocbio/io/tiff_h_4_0_8.py'
unexpected EOF while parsing (<string>, line 1): '(1'
unexpected EOF while parsing (<string>, line 1): '(1'
unexpected EOF while parsing (<string>, line 1): '(1'
unexpected EOF while parsing (<string>, line 1): '(1'
unexpected EOF while parsing (<string>, line 1): '(1'
unexpected EOF while parsing (<string>, line 1): '(1'
>>> 

Issue seems to be triggered by

grep -r CODINGMETHODS /usr/include
/usr/include/tiff.h:#define TIFFTAG_CODINGMETHODS		403	/* !TIFF/FX coding methods */
/usr/include/tiff.h:#define     CODINGMETHODS_T4_1D		(1 << 1)	/* !T.4 1D */
/usr/include/tiff.h:#define     CODINGMETHODS_T4_2D		(1 << 2)	/* !T.4 2D */
/usr/include/tiff.h:#define     CODINGMETHODS_T6		(1 << 3)	/* !T.6 */
/usr/include/tiff.h:#define     CODINGMETHODS_T85 		(1 << 4)	/* !T.85 JBIG */
/usr/include/tiff.h:#define     CODINGMETHODS_T42 		(1 << 5)	/* !T.42 JPEG */
/usr/include/tiff.h:#define     CODINGMETHODS_T43		(1 << 6)	/* !T.43 colour by layered JBIG */

leading to

TIFFTAG_CODINGMETHODS = 403
CODINGMETHODS_T4_1D = (1
CODINGMETHODS_T4_2D = (1
CODINGMETHODS_T6 = (1
CODINGMETHODS_T85 = (1
CODINGMETHODS_T42 = (1
CODINGMETHODS_T43 = (1

in tiff_h_4_0_8.py

Save incorrectly the image read

I am not able to save a tiff image rgba float32 correctly
Looks like an array order:

from libtiff import TIFF, TIFFimage

    tif = TIFF.open("test3.tif", mode='r')
    image_read = tif.read_image()
    print image_read.shape
    image_save = TIFFimage(image_read)
    image_save.write_file("out.tif")
iinfo -v out.tif
out.tif :    4 x 1024, 1 channel, float tiff
1024 subimages

the image to test is a 10x10x4 float32 (rgba) file
https://infinit.io/_/KCdNUuH

Tiff Exploit For PSP

Hi

We are founded exploit for psp system but sony patched it please make same 
this for me 


Exp:http://www.multiupload.com/EKU1LXZDWW (same this)

Sorry for my english




Original issue reported on code.google.com by [email protected] on 15 May 2010 at 8:41

installing through pip fails in python 3

> pip install libtiff
Collecting libtiff
  Downloading libtiff-0.4.0.tar.gz (119kB)
    100% |████████████████████████████████| 122kB 2.9MB/s
    Complete output from command python setup.py egg_info:
    Warning: Assuming default configuration (libtiff/bitarray-0.3.5-numpy/bitarray/{setup_bitarray,setup}.py was not found)Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/tv/0sj3cm251x14b29kb6xzs27r0000gn/T/pip-build-nwvzm3eq/libtiff/setup.py", line 96, in <module>
        configuration = configuration,
      File "/Users/waspinator/anaconda/lib/python3.5/site-packages/numpy/distutils/core.py", line 135, in setup
        config = configuration()
      File "/private/var/folders/tv/0sj3cm251x14b29kb6xzs27r0000gn/T/pip-build-nwvzm3eq/libtiff/setup.py", line 67, in configuration
        config.get_version('libtiff/version.py')
      File "/Users/waspinator/anaconda/lib/python3.5/site-packages/numpy/distutils/misc_util.py", line 1917, in get_version
        fn, info)
      File "/Users/waspinator/anaconda/lib/python3.5/site-packages/numpy/compat/py3k.py", line 112, in npy_load_module
        return importlib.machinery.SourceFileLoader(name, fn).load_module()
      File "<frozen importlib._bootstrap_external>", line 388, in _check_name_wrapper
      File "<frozen importlib._bootstrap_external>", line 809, in load_module
      File "<frozen importlib._bootstrap_external>", line 668, in load_module
      File "<frozen importlib._bootstrap>", line 268, in _load_module_shim
      File "<frozen importlib._bootstrap>", line 693, in _load
      File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 661, in exec_module
      File "<frozen importlib._bootstrap_external>", line 767, in get_code
      File "<frozen importlib._bootstrap_external>", line 727, in source_to_code
      File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
      File "libtiff/version.py", line 30
        print version
                    ^
    SyntaxError: Missing parentheses in call to 'print'
    Appending libtiff.bitarray configuration to libtiff
    Ignoring attempt to set 'name' (from 'libtiff' to 'libtiff.bitarray')
    Appending libtiff configuration to
    Ignoring attempt to set 'name' (from '' to 'libtiff')

Reading tiffarray of large images

What steps will reproduce the problem?
from libtiff import TIFFfile
tif=TIFFfile("3D_sliced_tiff_image_of_800MB.tiff")
tif.get_tiff_array()[:]

What is the expected output? What do you see instead?
I expect a 3D array
I get IndexError: tuple index out of range from the line 35 (function 
__get_item__(self, index) of tiff_array.py :
indices = range (*index.indices(self.shape[0]))

What version of the product are you using? On what operating system?
/pylibtiff-0.3.0.dev78-py2.7
on Ubuntu 11.10

Please provide any additional information below.
The function works on the same image if I crop it before (800MB to 200MB)

Original issue reported on code.google.com by [email protected] on 2 Feb 2012 at 2:39

Support for EXIF tags

I added basic EXIF tag support, which gets the job done but definitely needs 
work.

It just detects if TIFFTAG_EXIFIFD exists, and loads it by looping through the 
IFD loading loop (in tiff_file.py) one last time with the proper offset. Thus 
the additional code added is quite minimal. Also in the patch is a change to 
tiff_data.py which includes EXIF tag info. Not all of them though, I just added 
the main ones that were in my photos. The complete list is located at: 
http://www.awaresystems.be/imaging/tiff/tifftags/privateifd/exif.html

Attached is the patch, test program, and sample output.

Original issue reported on code.google.com by [email protected] on 25 Aug 2011 at 10:32

Attachments:

how pylibtiff can work in Windows Xp system?

1,I download the libtiff.py and setup.py  ,after I install then in my  win 
XP system ,it also have some problem with me,I find the no.21 line of the 
libtiff.py file,the script of it is "include_tiff_h 
= '/usr/include/tiff.h'",   this path is in linux system ,so I think 
that ,can this tool work in Xp system?

Original issue reported on code.google.com by [email protected] on 27 Sep 2009 at 12:26

not able to install libtiff on linux

I ve just wanted to install the libtiff but not able to run it or even import.
I used pip install libtiff to get latest version which which run fine but later on calling import libtiff crash... I found I have libtiff5 on my computer so I compiled and installed libtiff-4.0.6 from source and uninstall libtift and installed again, but it does not help...

Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libtiff
Generating '/usr/local/lib/python2.7/dist-packages/libtiff/tiff_h_4_0_6.py'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/libtiff/__init__.py", line 20, in <module>
    from .libtiff_ctypes import libtiff, TIFF, TIFF3D
  File "/usr/local/lib/python2.7/dist-packages/libtiff/libtiff_ctypes.py", line 102, in <module>
    f = open(fn, 'w')
IOError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/libtiff/tiff_h_4_0_6.py'

In the end it /usr/local/lib/python2.7/dist-packages/libtiff/tiff_h_4_0_6.py does not exits

Disabling unknown field warnings (`TIFFSetWarningHandler` option)

Hi,

When reading an image stack with libtiff.TIFF I often get the following warning message:

TIFFReadDirectory: Warning, Unknown field with tag 32781 (0x800d) encountered.
TIFFFetchNormalTag: Warning, ASCII value for tag "ImageDescription" does not end in null byte.

I have read (here) that the original libtiff library provides a way to disable them through the option TIFFSetWarningHandler(0), however, I cannot find the option in pylibtiff. Is this option available?

If not, this option would really be helpful: when loading a movie of 3D pictures, it frequently happens that I get thousands of warning that overflow my console.
Thank you

Writing a field with an empty string segfault with the C wrapper

What steps will reproduce the problem?
>>> from libtiff import TIFF
>>> import numpy
>>> tif = TIFF.open('filename.tif', mode='w')
>>> tif.SetField("ImageDescription", "")
Segmentation fault (core dumped)

What is the expected output? What do you see instead?
>>> from libtiff import TIFF
>>> import numpy
>>> tif = TIFF.open('filename.tif', mode='w')
>>> tif.SetField("ImageDescription", "")
>>> tif.write_image(numpy.zeros((20,20)))
>>> tif.close()

$ tiffinfo filename.tif 
TIFF Directory at offset 0xc88 (3208)
  Image Width: 20 Image Length: 20
  Bits/Sample: 64
  Sample Format: IEEE floating point
  Compression Scheme: None
  Photometric Interpretation: min-is-black
  Orientation: row 0 top, col 0 lhs
  Planar Configuration: single image plane
  ImageDescription: 



What version of the product are you using? On what operating system?
svn HEAD (rev 93) (on Ubuntu 12.04)

Please provide any additional information below.
This is due to the SetField() wrapper which is confused because Python strings 
are iterable, but ctype needs to convert them as a simple type.

Attached is a patch that fixes this. This patch can also be found here: 
https://github.com/delmic/pylibtiff/commit/9bbdd48321dacbe0be418adf77c2cc063c355
8ab

PS: the patch also fixes a few other minor issues, let me know if you prefer a 
patch which does only the very minimum to fix this issue.

Original issue reported on code.google.com by [email protected] on 21 Aug 2013 at 4:29

Attachments:

tests fail on all os.remove() on Windows

Temporary files are locked on Windows, so they can not be removed without 
closing beforehand.

Log file of nosetests on Windows 7, VS2008, Python 2.7 attached. 

I tried to fix the error by calling .close() method on objects that opened the 
files, deleting mmaped variables and/or TIFFfile or TIFFimage instances before 
calling os.remove(). It didn't solve the issue unfortunately. The mmaped numpy 
arrays are somehow still open.

Original issue reported on code.google.com by [email protected] on 8 Nov 2011 at 9:06

Attachments:

Unknown TIFF tags

TIFFReadDirectory: Warning, Unknown field with tag 33550 (0x830e) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 33922 (0x8482) encountered.
TIFFReadDirectory: Warning, Unknown field with tag 34735 (0x87af) encountered.

What steps will reproduce the problem?
1. open
2. read_image

What is the expected output? What do you see instead?
No warnings

What version of the product are you using? On what operating system?
Windows 7/64, Python 2.7

Please provide any additional information below.
Sample file attached

Original issue reported on code.google.com by [email protected] on 17 Aug 2013 at 2:30

Attachments:

Failure to import tif_lzw

What steps will reproduce the problem?
1. I am using the Canopy Python installation v 1.1.1.1452, which includes 
Enthought Canopy Python 2.7.3 | 64-bit [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] 
on linux2. I also installed tiff-4.0.3 from source. I set LD_LIBRARY_PATH to 
include the Enthought Python lib directory, and subsequently the libtiff 
directory in site-packages.
2. I downloaded pylibtiff using 'svn checkout 
http://pylibtiff.googlecode.com/svn/trunk/ pylibtiff-read-only' and ran python 
setup.py install. 
3. I ran nosetests libtiff/tests/ from the pylibtiff-read-only directory.

What is the expected output? What do you see instead?
I get the following output with an import error for tif_lzw.:

$ nosetests libtiff/tests/
EEEEE
======================================================================
ERROR: Failure: ImportError (No module named tif_lzw)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/loader.py", line 413, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tests/test_lzw.py", line 4, in <module>
    from libtiff import TIFFfile, TIFF
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/__init__.py", line 21, in <module>
    from .tiff import TIFFfile, TIFFimage, TiffArray
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff.py", line 25, in <module>
    from .tiff_file import TIFFfile
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff_file.py", line 20, in <module>
    from .tiff_sample_plane import TiffSamplePlane
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff_sample_plane.py", line 8, in <module>
    import tif_lzw
ImportError: No module named tif_lzw

======================================================================
ERROR: Failure: ImportError (No module named tif_lzw)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/loader.py", line 413, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tests/test_simple.py", line 5, in <module>
    from libtiff import TIFF
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/__init__.py", line 21, in <module>
    from .tiff import TIFFfile, TIFFimage, TiffArray
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff.py", line 25, in <module>
    from .tiff_file import TIFFfile
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff_file.py", line 20, in <module>
    from .tiff_sample_plane import TiffSamplePlane
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff_sample_plane.py", line 8, in <module>
    import tif_lzw
ImportError: No module named tif_lzw

======================================================================
ERROR: Failure: ImportError (No module named tif_lzw)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/loader.py", line 413, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tests/test_tiff_array.py", line 6, in <module>
    from libtiff import TIFF
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/__init__.py", line 21, in <module>
    from .tiff import TIFFfile, TIFFimage, TiffArray
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff.py", line 25, in <module>
    from .tiff_file import TIFFfile
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff_file.py", line 20, in <module>
    from .tiff_sample_plane import TiffSamplePlane
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff_sample_plane.py", line 8, in <module>
    import tif_lzw
ImportError: No module named tif_lzw

======================================================================
ERROR: Failure: ImportError (No module named tif_lzw)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/loader.py", line 413, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tests/test_tiff_file.py", line 6, in <module>
    from libtiff import TIFF
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/__init__.py", line 21, in <module>
    from .tiff import TIFFfile, TIFFimage, TiffArray
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff.py", line 25, in <module>
    from .tiff_file import TIFFfile
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff_file.py", line 20, in <module>
    from .tiff_sample_plane import TiffSamplePlane
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff_sample_plane.py", line 8, in <module>
    import tif_lzw
ImportError: No module named tif_lzw

======================================================================
ERROR: Failure: ImportError (No module named tif_lzw)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/loader.py", line 413, in loadTestsFromName
    addr.filename, addr.module)
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/home/rosborn/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tests/test_tiff_image.py", line 5, in <module>
    from libtiff import TIFFfile, TIFFimage, TIFF
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/__init__.py", line 21, in <module>
    from .tiff import TIFFfile, TIFFimage, TiffArray
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff.py", line 25, in <module>
    from .tiff_file import TIFFfile
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff_file.py", line 20, in <module>
    from .tiff_sample_plane import TiffSamplePlane
  File "/autonfs/home/rosborn/downloads/pylibtiff-read-only/libtiff/tiff_sample_plane.py", line 8, in <module>
    import tif_lzw
ImportError: No module named tif_lzw

----------------------------------------------------------------------
Ran 5 tests in 0.449s

FAILED (errors=5)

If I succeed in suppressing the tif_lzw import error (by commenting out the 
imports), I get a segmentation fault.

Original issue reported on code.google.com by [email protected] on 30 Oct 2013 at 6:58

error in importing libtiff

I am trying to use pylibtiff to read tiff files into numpy array.. i installed 
the windows installer provided on the site and now if i try importing, python 
encounters with following error:

>>> from libtiff import *

Traceback (most recent call last):
  File "D:/Python27/testtifflib.py", line 4, in <module>
    from libtiff import *
  File "D:\Python27\lib\site-packages\libtiff\__init__.py", line 4, in <module>
    from .libtiff import libtiff, TIFF
  File "D:\Python27\lib\site-packages\libtiff\libtiff.py", line 35, in <module>
    raise ImportError('Failed to find TIFF library. Make sure that libtiff is installed and its location is listed in PATH|LD_LIBRARY_PATH|..')
ImportError: Failed to find TIFF library. Make sure that libtiff is installed 
and its location is listed in PATH|LD_LIBRARY_PATH|..

i also tried this :

import sys
sys.path.append("D:\\Python27\\Lib\\site-packages\\libtiff")

from libtiff import *

but same error persists.. what can be done in this case??  any help is 
appreciated.. m i missing something here??


Original issue reported on code.google.com by [email protected] on 2 Feb 2011 at 12:35

Let's put pylibtiff on PyPI so that other packages can install it as a dependency.

Can pylibtiff join the Python Package Index at pypi.python.org/pypi so that 
it's easy for other packages to depend on it? If you're not sure you have the 
time, I'd be happy to upload it myself and send you the relevant authentication 
info.

I maintain a package called PIMS (https://github.com/soft-matter/pims) that 
uses pylibtiff and other libraries to read sequential images in various formats 
using a consistent interface.

Once pylibtiff is on PyPI it will be possible to

   pip install pylibtiff

and then I can set it up such that

    pip install pims

automatically installs pylibtiff as well. Thanks!

Dan Allan

Original issue reported on code.google.com by [email protected] on 13 Sep 2014 at 6:03

README.txt is out-of-date

The readme file says to import with
from pylibtiff import *

The correct import is
from libtiff.libtiff import *

Original issue reported on code.google.com by [email protected] on 4 Jan 2010 at 10:27

Issue running with numpy > 1.7 on ubuntu 15

I continue to get 'Segmentation Fault (core dumped)' errors upon importing libtiff under Numpy versions > 1.7. I can get the package to work if I compile using numpy 1.7 and stay on 1.7 but it fails if I update to later versions of numpy (1.9 or 1.10). I was wondering if there was a quick fix for this that I am missing. I traced the problem back to the compiled version of tif_lzw.so and have attached the error dialog below. Any help in diagnosing this issue would be much appreciated.

Current thread 0x00007f6bc93c1700 (most recent call first):
  File "/home/francisco/anaconda2/lib/python2.7/site-packages/libtiff/tiff_sample_plane.py", line 8 in <module>
  File "/home/francisco/anaconda2/lib/python2.7/site-packages/libtiff/tiff_file.py", line 20 in <module>
  File "/home/francisco/anaconda2/lib/python2.7/site-packages/libtiff/tiff.py", line 25 in <module>
  File "/home/francisco/anaconda2/lib/python2.7/site-packages/libtiff/__init__.py", line 21 in <module>
Segmentation fault (core dumped)

TIFFimage and RGB

is it possible to write RGB tiff files by means of python module ?

i can only obtain a GRAY file with width multiplied by 3.

i quickly read sources and i don't understand how to set photometric and 
samplesperpixel tags.


Original issue reported on code.google.com by [email protected] on 23 Aug 2011 at 10:28

import libtiff fails

--problem--:
1) can't eval (1
2) TIFFTAG_* undefined

--solution--:
sed -i "s/\.split()\[:2\]/\.split(None,1)/;\
      s/eval(value)/eval(value,d)/" libtiff/libtiff_ctypes.py

python=2.7.3
libtiff=4.0.3

Original issue reported on code.google.com by [email protected] on 16 Oct 2012 at 10:13

bittools extension fails to compile on Fedora 18 (python 2.7.3, gcc 4.7.2, numpy 1.7.0)

I checked out rev. 89 from svn and attempted to build from source in the usual 
way (python setup.py build / sudo python setup.py install), but the build 
choked on the bittools extension. A log is attached. It looks as though the 
problem may be numpy-1.7.0-related. (I just watched someone successfully 
install on an Ubuntu 12.04 system with numpy 1.6.2, same gcc and python.)

Original issue reported on code.google.com by [email protected] on 10 Apr 2013 at 1:33

Attachments:

Cannot be installed with Python3 (even after 2to3 translator)

What steps will reproduce the problem?

1. direct installation with pip3 or easy_install returns a problem with `print`

2. after translation of the code with `2to3` the problem with `_bitarray.c` 
arises:

    bitarray-0.3.5-numpy/bitarray/_bitarray.c:2520:17: error: ‘PyTypeObject’ has no member named ‘ob_type’
         Bitarraytype.ob_type = &PyType_Type;

Original issue reported on code.google.com by [email protected] on 21 Mar 2015 at 7:57

RGB image format doesn't follow the standard numpy RGB format

write_image() supports RGB image if write_rgb=True is passed, but it expects an 
numpy array in the format 3xMxN for an image of MxN pixels, while the normal 
RGB images in numpy are encoded MxNx3. 

For reference, see the documentation here:
http://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.imread.html

As a workaround, I currently send a view of my array with axes swapped to 
write_image. Like this:
image = scipy.ndimage.imread("test.jpg")
image_sw = image.swapaxes(2,0).swapaxes(2,1)
tif.write_image(image_sw, write_rgb=True)


I can try to provide a patch if you're interested.

Original issue reported on code.google.com by [email protected] on 9 Oct 2012 at 9:03

TIFF wrapper compatibility broken due to all function names being lowercase.

The latest git HEAD, since commit bdce54f, has broken compatibility with all our code.
All the methods of the TIFF class have been renamed to only be lowercase.

So simple code like this is broken:

    f = TIFF.open(fn, mode='r')
    if f.IsTiled():
        bits = f.GetField('BitsPerSample')
        sample_format = f.GetField('SampleFormat')
        typ = f.get_numpy_type(bits, sample_format)
        im = f.read_tiles(typ)
    else:
        im = f.read_image() # Fist image

Now, both .IsTiled() and .GetField() don't exist, as they've been renamed to .istiled() and getfield().
Note that the Python convention is to either have CamelCase, or lower_case names, however, it is not recommended to use lowercase without separation (because it makes names hard to read).

IMHO, in this case, as it's wrapper doing a simple mapping of C functions to Python methods, it makes sense to use the same convention as the C library, so that it's more obvious that they are just direct mapping. For the more complex methods, like read_image(), it's also fine to follow a different convention, as they are not a direct mapping of the C library, but additional helper code.

So, I'd suggest to revert the renaming of the methods. If needed, I can provide a patch.

`find_library` won't search `LD_LIBRARY_PATH` on Linux (need workaround)

This is a problem that arises with this line ( https://github.com/pearu/pylibtiff/blob/master/libtiff/libtiff_ctypes.py#L41 ). On Mac, one can set DYLD_LIBRARY_PATH and this has the expected behavior when using find_library. However, this is not the case on Linux with LD_LIBRARY_PATH. See this discussion about the issue in Python. ( https://bugs.python.org/issue2936 ) However, if LD_LIBRARY_PATH is set, this line ( https://github.com/pearu/pylibtiff/blob/master/libtiff/libtiff_ctypes.py#L43 ) will import the library given the right name (e.g. libtiff.so or libtiff.dylib) even though find_library fails. Also, PATH is not used on Mac.

fails to compile (Windows 7, VS2008, Python 2.7, numpy 1.6.1)

I run on SVN checkout:
python setup.py install

and got:
libtiff\src\tif_lzw.c(1276) : error C2036: 'void *' : unknown size

reason:

In numpy c interface (see 
https://github.com/numpy/numpy/blob/master/numpy/core/include/numpy/ndarraytypes
.h) was changed the return type of PyArray_DATA from void* in 1.6.1. to char* 
in current git head revision. PyArray_DATA also changed from macro to inline 
function but that should not matter.

Is it possible that pylibtiff works with current numpy from github and not with 
last stable numpy release?

I attach patch that allowed me to compile pylibtiff (the functionality is not 
tested). Also the installation log is attached.

Original issue reported on code.google.com by [email protected] on 7 Nov 2011 at 6:07

Attachments:

Segmentation fault at "from libtiff import TIFF" / dlopen(...tif_lzw.so") with python 2.6

What steps will reproduce the problem?
1. run enthought python distribution 6.3-2 on scientific linux 5
2. build/install pylibtiff (revision 70)
3. run python -c "from libtiff import TIFF"

What is the expected output? What do you see instead?
$ python -v -d -c "from libtiff import TIFF"
....

import copy # precompiled from /scratch/epd-6.3-2-rh5-x86/lib/python2.6/copy.pyc
# /scratch/pylibtiff.i386/lib/python/libtiff/tiff_base.pyc matches 
/scratch/pylibtiff.i386/lib/python/libtiff/tiff_base.py
import libtiff.tiff_base # precompiled from 
/scratch/pylibtiff.i386/lib/python/libtiff/tiff_base.pyc
# /scratch/pylibtiff.i386/lib/python/libtiff/lsm.pyc matches 
/scratch/pylibtiff.i386/lib/python/libtiff/lsm.py
import libtiff.lsm # precompiled from 
/scratch/pylibtiff.i386/lib/python/libtiff/lsm.pyc
dlopen("/scratch/pylibtiff.i386/lib/python/libtiff/tif_lzw.so", 102);
Segmentation fault



What version of the product are you using? On what operating system?

$ python -V
Python 2.6.6 -- EPD 6.3-2 (32-bit)

$ uname -a
Linux pc6490 2.6.18-194.26.1.el5 #1 SMP Tue Nov 9 12:56:26 EST 2010 i686 i686 
i386 GNU/Linux


Please provide any additional information below.

Works o.k. with python 2.7. 


Original issue reported on code.google.com by [email protected] on 19 Jan 2011 at 2:17

Setting Resolution tags in header seems broken

What steps will reproduce the problem?

Under Ipython -pylab
import libtiff
yy = (100*rand(100,100) ).astype('int32')
testTiff = libtiff.TIFF.open('brokenHeaders.tiff', 'w')
testTiff.SetField('XRESOLUTION', 1)
testTiff.GetField('XRESOLUTION')

What is the expected output? What do you see instead?
The output should obviously be 1.0 .  I get the same value whether
my input is 1, 100 or any other number as int or float data types.

Instead I see:

out = -0.024263981729745865 

What version of the product are you using? On what operating system?
I'm running Debian linux with KDE.
Python => v.  2.5.2-3
Ipython => v. .8.4.1




Original issue reported on code.google.com by [email protected] on 7 Oct 2009 at 9:46

TIFF.write_image writes incorrect ORIENTATION tag

What steps will reproduce the problem?
1.  Write image data using TIFF.open(filename, 'w').write(data)

What is the expected output? What do you see instead?

The created diff file has orientation 6 (

The offending lines are in libtiff_ctypes.py, lines 403, 420, and 453:

self.SetField(TIFFTAG_ORIENTATION, ORIENTATION_RIGHTTOP)

The correct value is 1, not 6.  See, for example,

http://www.awaresystems.be/imaging/tiff/tifftags/orientation.html

Note also that simply not setting the orientation tag also results in a correct 
image.

What version of the product are you using? On what operating system?

pylibtiff 0.1svn, Linux Ubuntu 10.10


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 25 Nov 2011 at 10:14

Does work for 1bit compressed TIFF

It seems that the library is working well for greyscale and color images, but 
as soon as a pure black&white (1bit/1plan) is given, it fails and renders a 
totally black image

I suppose there is something to do in read_image function cause I saw some 
comments in the code saying "TODO: check for correctness"




Original issue reported on code.google.com by [email protected] on 11 Mar 2011 at 4:07

incorrectly imports big-endian 16bit uints

What steps will reproduce the problem?
1. load data from a big-endian uint16 file

What is the expected output? What do you see instead?

It looks like the bytes are not swapped so the returned values are in the bit 
order ([8, 9, .. 15, 0, 1, ... 7]).  

There is already a function `IsByteSwapped` which will determine if the swap is 
needed.  

What version of the product are you using? On what operating system?

 master, linux

See test images at 
https://github.com/soft-matter/pims/blob/master/pims/tests/data/stuck.tif

Original issue reported on code.google.com by [email protected] on 28 Jan 2014 at 3:23

Use warnings.warn in tiff_file.py: get_values instead of stderr

I may have non-standard tiff files. Loading them tiff.TIFFfile writes an error to stderr, but the result is usable nevertheless.

get_values: incomplete info for type=7 ['7']: dtype=None, bytes=1

I expect pylibtiff to use warnings.warn instead, so that the user may handle such cases.

Fail to import libtiff in Ubuntu 14.04

What steps will reproduce the problem?
1.import libtiff


What is the expected output? What do you see instead?
Failed to find TIFF header file (may be need to run: sudo apt-get install 
libtiff4-dev)

What version of the product are you using? On what operating system?
Ubuntu 14.04

Please provide any additional information below.
Ubuntu 14.04 come with libtiff5 by default, replace it with libtiff4 seems not 
a simple task since several hundreds of package depends on libtiff5.

Original issue reported on code.google.com by [email protected] on 10 Sep 2014 at 8:50

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.