large-image-source-tiff 1.28.2__tar.gz → 1.28.2.dev2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of large-image-source-tiff might be problematic. Click here for more details.

Files changed (17) hide show
  1. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/PKG-INFO +3 -3
  2. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/large_image_source_tiff/__init__.py +9 -42
  3. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/large_image_source_tiff/tiff_reader.py +4 -4
  4. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/large_image_source_tiff.egg-info/PKG-INFO +3 -3
  5. large-image-source-tiff-1.28.2.dev2/large_image_source_tiff.egg-info/requires.txt +6 -0
  6. large-image-source-tiff-1.28.2/large_image_source_tiff.egg-info/requires.txt +0 -6
  7. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/LICENSE +0 -0
  8. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/README.rst +0 -0
  9. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/large_image_source_tiff/exceptions.py +0 -0
  10. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/large_image_source_tiff/girder_source.py +0 -0
  11. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/large_image_source_tiff.egg-info/SOURCES.txt +0 -0
  12. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/large_image_source_tiff.egg-info/dependency_links.txt +0 -0
  13. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/large_image_source_tiff.egg-info/entry_points.txt +0 -0
  14. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/large_image_source_tiff.egg-info/top_level.txt +0 -0
  15. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/pyproject.toml +0 -0
  16. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/setup.cfg +0 -0
  17. {large-image-source-tiff-1.28.2 → large-image-source-tiff-1.28.2.dev2}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: large-image-source-tiff
3
- Version: 1.28.2
3
+ Version: 1.28.2.dev2
4
4
  Summary: A TIFF tilesource for large_image.
5
5
  Home-page: https://github.com/girder/large_image
6
6
  Author: Kitware, Inc.
@@ -17,11 +17,11 @@ Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Requires-Python: >=3.8
19
19
  License-File: LICENSE
20
- Requires-Dist: large-image>=1.28.2
20
+ Requires-Dist: large-image>=1.28.2.dev2
21
21
  Requires-Dist: pylibtiff
22
22
  Requires-Dist: tifftools>=1.2.0
23
23
  Provides-Extra: girder
24
- Requires-Dist: girder-large-image>=1.28.2; extra == "girder"
24
+ Requires-Dist: girder-large-image>=1.28.2.dev2; extra == "girder"
25
25
 
26
26
  A TIFF tilesource for large_image.
27
27
 
@@ -73,7 +73,6 @@ class TiffFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
73
73
  }
74
74
 
75
75
  _maxAssociatedImageSize = 8192
76
- _maxUntiledImage = 4096
77
76
 
78
77
  def __init__(self, path, **kwargs): # noqa
79
78
  """
@@ -86,18 +85,18 @@ class TiffFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
86
85
 
87
86
  self._largeImagePath = str(self._getLargeImagePath())
88
87
 
89
- lastException = None
90
88
  try:
91
89
  self._initWithTiffTools()
92
90
  return
93
91
  except Exception as exc:
94
92
  self.logger.debug('Cannot read with tifftools route; %r', exc)
95
- lastException = exc
96
93
 
97
94
  alldir = []
98
95
  try:
99
96
  if hasattr(self, '_info'):
100
97
  alldir = self._scanDirectories()
98
+ else:
99
+ lastException = 'Could not parse file with tifftools'
101
100
  except IOOpenTiffError:
102
101
  msg = 'File cannot be opened via tiff source.'
103
102
  raise TileSourceError(msg)
@@ -158,7 +157,7 @@ class TiffFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
158
157
  tifftools.constants.SampleFormat[sampleformat or 1].name,
159
158
  bitspersample,
160
159
  ))
161
- self._bandCount = highest._tiffInfo.get('samplesperpixel', 1)
160
+ self._bandCount = highest._tiffInfo.get('samplesperpixel')
162
161
  # Sort the directories so that the highest resolution is the last one;
163
162
  # if a level is missing, put a None value in its place.
164
163
  self._tiffDirectories = [directories.get(key) for key in
@@ -253,13 +252,8 @@ class TiffFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
253
252
  """
254
253
  sizeX = ifd['tags'][tifftools.Tag.ImageWidth.value]['data'][0]
255
254
  sizeY = ifd['tags'][tifftools.Tag.ImageLength.value]['data'][0]
256
- if tifftools.Tag.TileWidth.value in baseifd['tags']:
257
- tileWidth = baseifd['tags'][tifftools.Tag.TileWidth.value]['data'][0]
258
- tileHeight = baseifd['tags'][tifftools.Tag.TileLength.value]['data'][0]
259
- else:
260
- tileWidth = sizeX
261
- tileHeight = baseifd['tags'][tifftools.Tag.RowsPerStrip.value]['data'][0]
262
-
255
+ tileWidth = baseifd['tags'][tifftools.Tag.TileWidth.value]['data'][0]
256
+ tileHeight = baseifd['tags'][tifftools.Tag.TileLength.value]['data'][0]
263
257
  for tag in {
264
258
  tifftools.Tag.SamplesPerPixel.value,
265
259
  tifftools.Tag.BitsPerSample.value,
@@ -304,7 +298,7 @@ class TiffFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
304
298
  directories are the same size and format; all non-tiled directories are
305
299
  treated as associated images.
306
300
  """
307
- dir0 = self.getTiffDir(0, mustBeTiled=None)
301
+ dir0 = self.getTiffDir(0)
308
302
  self.tileWidth = dir0.tileWidth
309
303
  self.tileHeight = dir0.tileHeight
310
304
  self.sizeX = dir0.imageWidth
@@ -318,11 +312,12 @@ class TiffFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
318
312
  tifftools.constants.SampleFormat[sampleformat or 1].name,
319
313
  bitspersample,
320
314
  ))
321
- self._bandCount = dir0._tiffInfo.get('samplesperpixel', 1)
315
+ self._bandCount = dir0._tiffInfo.get('samplesperpixel')
322
316
  info = _cached_read_tiff(self._largeImagePath)
323
317
  self._info = info
324
318
  frames = []
325
319
  associated = [] # for now, a list of directories
320
+ curframe = -1
326
321
  for idx, ifd in enumerate(info['ifds']):
327
322
  # if not tiles, add to associated images
328
323
  if tifftools.Tag.tileWidth.value not in ifd['tags']:
@@ -331,6 +326,7 @@ class TiffFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
331
326
  level = self._levelFromIfd(ifd, info['ifds'][0])
332
327
  # if the same resolution as the main image, add a frame
333
328
  if level == self.levels - 1:
329
+ curframe += 1
334
330
  frames.append({'dirs': [None] * self.levels})
335
331
  frames[-1]['dirs'][-1] = (idx, 0)
336
332
  try:
@@ -369,35 +365,6 @@ class TiffFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
369
365
  else:
370
366
  msg = 'Tile layers are in a surprising order'
371
367
  raise TileSourceError(msg)
372
- # If we have a single untiled ifd that is "small", use it
373
- if tifftools.Tag.tileWidth.value not in info['ifds'][0]['tags']:
374
- if (
375
- self.sizeX > self._maxUntiledImage or self.sizeY > self._maxUntiledImage or
376
- (len(info['ifds']) != 1 or tifftools.Tag.SubIfd.value in ifd['tags']) or
377
- (tifftools.Tag.ImageDescription.value in ifd['tags'] and
378
- 'ImageJ' in ifd['tags'][tifftools.Tag.ImageDescription.value]['data'])
379
- ):
380
- msg = 'A tiled TIFF is required.'
381
- raise ValidationTiffError(msg)
382
- associated = []
383
- level = self._levelFromIfd(ifd, info['ifds'][0])
384
- frames.append({'dirs': [None] * self.levels})
385
- frames[-1]['dirs'][-1] = (idx, 0)
386
- try:
387
- frameMetadata = json.loads(
388
- ifd['tags'][tifftools.Tag.ImageDescription.value]['data'])
389
- for key in {'channels', 'frame'}:
390
- if key in frameMetadata:
391
- frames[-1][key] = frameMetadata[key]
392
- except Exception:
393
- pass
394
- if tifftools.Tag.ICCProfile.value in ifd['tags']:
395
- if not hasattr(self, '_iccprofiles'):
396
- self._iccprofiles = []
397
- while len(self._iccprofiles) < len(frames) - 1:
398
- self._iccprofiles.append(None)
399
- self._iccprofiles.append(ifd['tags'][
400
- tifftools.Tag.ICCProfile.value]['data'])
401
368
  self._associatedImages = {}
402
369
  for dirNum in associated:
403
370
  self._addAssociatedImage(dirNum)
@@ -207,8 +207,8 @@ class TiledTiffDirectory:
207
207
  # the create_image.py script, such as flatten or colourspace. These
208
208
  # should only be done if necessary, which would require the conversion
209
209
  # job to check output and perform subsequent processing as needed.
210
- if (not self._tiffInfo.get('samplesperpixel', 1) or
211
- self._tiffInfo.get('samplesperpixel', 1) < 1):
210
+ if (not self._tiffInfo.get('samplesperpixel') or
211
+ self._tiffInfo.get('samplesperpixel') < 1):
212
212
  msg = 'Only RGB and greyscale TIFF files are supported'
213
213
  raise ValidationTiffError(msg)
214
214
 
@@ -607,7 +607,7 @@ class TiledTiffDirectory:
607
607
  self._tiffInfo.get('bitspersample'),
608
608
  self._tiffInfo.get('sampleformat') if self._tiffInfo.get(
609
609
  'sampleformat') is not None else libtiff_ctypes.SAMPLEFORMAT_UINT)
610
- image = np.empty((th, tw, self._tiffInfo.get('samplesperpixel', 1)),
610
+ image = np.empty((th, tw, self._tiffInfo['samplesperpixel']),
611
611
  dtype=_ctypesFormattbl[format])
612
612
  imageBuffer = image.ctypes.data_as(ctypes.POINTER(ctypes.c_char))
613
613
  if self._tiffInfo.get('istiled'):
@@ -635,7 +635,7 @@ class TiledTiffDirectory:
635
635
  raise IOTiffError(
636
636
  'Read an unexpected number of bytes from an encoded tile' if readSize >= 0 else
637
637
  'Failed to read from an encoded tile')
638
- if (self._tiffInfo.get('samplesperpixel', 1) == 3 and
638
+ if (self._tiffInfo.get('samplesperpixel') == 3 and
639
639
  self._tiffInfo.get('photometric') == libtiff_ctypes.PHOTOMETRIC_YCBCR):
640
640
  if self._tiffInfo.get('bitspersample') == 16:
641
641
  image = np.floor_divide(image, 256).astype(np.uint8)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: large-image-source-tiff
3
- Version: 1.28.2
3
+ Version: 1.28.2.dev2
4
4
  Summary: A TIFF tilesource for large_image.
5
5
  Home-page: https://github.com/girder/large_image
6
6
  Author: Kitware, Inc.
@@ -17,11 +17,11 @@ Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Requires-Python: >=3.8
19
19
  License-File: LICENSE
20
- Requires-Dist: large-image>=1.28.2
20
+ Requires-Dist: large-image>=1.28.2.dev2
21
21
  Requires-Dist: pylibtiff
22
22
  Requires-Dist: tifftools>=1.2.0
23
23
  Provides-Extra: girder
24
- Requires-Dist: girder-large-image>=1.28.2; extra == "girder"
24
+ Requires-Dist: girder-large-image>=1.28.2.dev2; extra == "girder"
25
25
 
26
26
  A TIFF tilesource for large_image.
27
27
 
@@ -0,0 +1,6 @@
1
+ large-image>=1.28.2.dev2
2
+ pylibtiff
3
+ tifftools>=1.2.0
4
+
5
+ [girder]
6
+ girder-large-image>=1.28.2.dev2
@@ -1,6 +0,0 @@
1
- large-image>=1.28.2
2
- pylibtiff
3
- tifftools>=1.2.0
4
-
5
- [girder]
6
- girder-large-image>=1.28.2