large-image-source-pil 1.23.3.dev62__tar.gz → 1.23.3.dev67__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.
Files changed (13) hide show
  1. {large-image-source-pil-1.23.3.dev62 → large-image-source-pil-1.23.3.dev67}/PKG-INFO +1 -1
  2. {large-image-source-pil-1.23.3.dev62 → large-image-source-pil-1.23.3.dev67}/large_image_source_pil/__init__.py +20 -16
  3. {large-image-source-pil-1.23.3.dev62 → large-image-source-pil-1.23.3.dev67}/large_image_source_pil/girder_source.py +6 -3
  4. {large-image-source-pil-1.23.3.dev62 → large-image-source-pil-1.23.3.dev67}/large_image_source_pil.egg-info/PKG-INFO +1 -1
  5. {large-image-source-pil-1.23.3.dev62 → large-image-source-pil-1.23.3.dev67}/large_image_source_pil.egg-info/requires.txt +2 -2
  6. {large-image-source-pil-1.23.3.dev62 → large-image-source-pil-1.23.3.dev67}/setup.py +3 -3
  7. {large-image-source-pil-1.23.3.dev62 → large-image-source-pil-1.23.3.dev67}/LICENSE +0 -0
  8. {large-image-source-pil-1.23.3.dev62 → large-image-source-pil-1.23.3.dev67}/README.rst +0 -0
  9. {large-image-source-pil-1.23.3.dev62 → large-image-source-pil-1.23.3.dev67}/large_image_source_pil.egg-info/SOURCES.txt +0 -0
  10. {large-image-source-pil-1.23.3.dev62 → large-image-source-pil-1.23.3.dev67}/large_image_source_pil.egg-info/dependency_links.txt +0 -0
  11. {large-image-source-pil-1.23.3.dev62 → large-image-source-pil-1.23.3.dev67}/large_image_source_pil.egg-info/entry_points.txt +0 -0
  12. {large-image-source-pil-1.23.3.dev62 → large-image-source-pil-1.23.3.dev67}/large_image_source_pil.egg-info/top_level.txt +0 -0
  13. {large-image-source-pil-1.23.3.dev62 → large-image-source-pil-1.23.3.dev67}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: large-image-source-pil
3
- Version: 1.23.3.dev62
3
+ Version: 1.23.3.dev67
4
4
  Summary: A Pillow tilesource for large_image.
5
5
  Home-page: https://github.com/girder/large_image
6
6
  Author: Kitware, Inc.
@@ -19,7 +19,7 @@ import math
19
19
  import os
20
20
  import threading
21
21
 
22
- import numpy
22
+ import numpy as np
23
23
  import PIL.Image
24
24
 
25
25
  import large_image
@@ -115,9 +115,9 @@ class PILFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
115
115
  try:
116
116
  maxSize = json.loads(maxSize)
117
117
  except Exception:
118
- raise TileSourceError(
119
- 'maxSize must be None, an integer, a dictionary, or a '
120
- 'JSON string that converts to one of those.')
118
+ msg = ('maxSize must be None, an integer, a dictionary, or a '
119
+ 'JSON string that converts to one of those.')
120
+ raise TileSourceError(msg)
121
121
  self.maxSize = maxSize
122
122
 
123
123
  largeImagePath = self._getLargeImagePath()
@@ -134,15 +134,18 @@ class PILFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
134
134
  except OSError:
135
135
  if not os.path.isfile(largeImagePath):
136
136
  raise TileSourceFileNotFoundError(largeImagePath) from None
137
- raise TileSourceError('File cannot be opened via PIL.')
137
+ msg = 'File cannot be opened via PIL.'
138
+ raise TileSourceError(msg)
138
139
  minwh = min(self._pilImage.width, self._pilImage.height)
139
140
  maxwh = max(self._pilImage.width, self._pilImage.height)
140
141
  # Throw an exception if too small or big before processing further
141
142
  if minwh <= 0:
142
- raise TileSourceError('PIL tile size is invalid.')
143
+ msg = 'PIL tile size is invalid.'
144
+ raise TileSourceError(msg)
143
145
  maxWidth, maxHeight = getMaxSize(maxSize, self.defaultMaxSize())
144
146
  if maxwh > max(maxWidth, maxHeight):
145
- raise TileSourceError('PIL tile size is too large.')
147
+ msg = 'PIL tile size is too large.'
148
+ raise TileSourceError(msg)
146
149
  self._checkForFrames()
147
150
  if self._pilImage.info.get('icc_profile', None):
148
151
  self._iccprofiles = [self._pilImage.info.get('icc_profile')]
@@ -157,10 +160,10 @@ class PILFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
157
160
  pilImageMode = self._pilImage.mode.split(';')[0]
158
161
  self._factor = None
159
162
  if pilImageMode in ('I', 'F'):
160
- imgdata = numpy.asarray(self._pilImage)
161
- maxval = 256 ** math.ceil(math.log(numpy.max(imgdata) + 1, 256)) - 1
163
+ imgdata = np.asarray(self._pilImage)
164
+ maxval = 256 ** math.ceil(math.log(np.max(imgdata) + 1, 256)) - 1
162
165
  self._factor = 255.0 / maxval
163
- self._pilImage = PIL.Image.fromarray(numpy.uint8(numpy.multiply(
166
+ self._pilImage = PIL.Image.fromarray(np.uint8(np.multiply(
164
167
  imgdata, self._factor)))
165
168
  self.sizeX = self._pilImage.width
166
169
  self.sizeY = self._pilImage.height
@@ -170,7 +173,8 @@ class PILFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
170
173
  self.levels = 1
171
174
  # Throw an exception if too big after processing
172
175
  if self.tileWidth > maxWidth or self.tileHeight > maxHeight:
173
- raise TileSourceError('PIL tile size is too large.')
176
+ msg = 'PIL tile size is too large.'
177
+ raise TileSourceError(msg)
174
178
 
175
179
  def _checkForFrames(self):
176
180
  self._frames = None
@@ -200,9 +204,9 @@ class PILFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
200
204
  elif rgb.shape[2] > 3:
201
205
  rgb = rgb[:, :, :3]
202
206
  self._pilImage = PIL.Image.fromarray(
203
- rgb.astype(numpy.uint8) if rgb.dtype != numpy.uint16 else rgb,
204
- ('RGB' if rgb.dtype != numpy.uint16 else 'RGB;16') if rgb.shape[2] == 3 else
205
- ('L' if rgb.dtype != numpy.uint16 else 'L;16'))
207
+ rgb.astype(np.uint8) if rgb.dtype != np.uint16 else rgb,
208
+ ('RGB' if rgb.dtype != np.uint16 else 'RGB;16') if rgb.shape[2] == 3 else
209
+ ('L' if rgb.dtype != np.uint16 else 'L;16'))
206
210
  except Exception:
207
211
  pass
208
212
 
@@ -269,8 +273,8 @@ class PILFileTileSource(FileTileSource, metaclass=LruCacheMetaclass):
269
273
  self._frameImage.seek(0)
270
274
  img.load()
271
275
  if self._factor:
272
- img = PIL.Image.fromarray(numpy.uint8(numpy.multiply(
273
- numpy.asarray(img), self._factor)))
276
+ img = PIL.Image.fromarray(np.uint8(np.multiply(
277
+ np.asarray(img), self._factor)))
274
278
  else:
275
279
  img = self._pilImage
276
280
  return self._outputTile(img, TILE_FORMAT_PIL, x, y, z,
@@ -53,11 +53,14 @@ class PILGirderTileSource(PILFileTileSource, GirderTileSource):
53
53
  def getTile(self, x, y, z, pilImageAllowed=False, numpyAllowed=False,
54
54
  mayRedirect=False, **kwargs):
55
55
  if z != 0:
56
- raise TileSourceError('z layer does not exist')
56
+ msg = 'z layer does not exist'
57
+ raise TileSourceError(msg)
57
58
  if x != 0:
58
- raise TileSourceError('x is outside layer')
59
+ msg = 'x is outside layer'
60
+ raise TileSourceError(msg)
59
61
  if y != 0:
60
- raise TileSourceError('y is outside layer')
62
+ msg = 'y is outside layer'
63
+ raise TileSourceError(msg)
61
64
  if (mayRedirect and not pilImageAllowed and not numpyAllowed and
62
65
  cherrypy.request and
63
66
  self._pilFormatMatches(self._pilImage, mayRedirect, **kwargs)):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: large-image-source-pil
3
- Version: 1.23.3.dev62
3
+ Version: 1.23.3.dev67
4
4
  Summary: A Pillow tilesource for large_image.
5
5
  Home-page: https://github.com/girder/large_image
6
6
  Author: Kitware, Inc.
@@ -1,4 +1,4 @@
1
- large-image>=1.23.3.dev62
1
+ large-image>=1.23.3.dev67
2
2
 
3
3
  [:python_version < "3.8"]
4
4
  importlib-metadata<5
@@ -8,4 +8,4 @@ rawpy
8
8
  pillow-heif
9
9
 
10
10
  [girder]
11
- girder-large-image>=1.23.3.dev62
11
+ girder-large-image>=1.23.3.dev67
@@ -66,10 +66,10 @@ setup(
66
66
  python_requires='>=3.6',
67
67
  entry_points={
68
68
  'large_image.source': [
69
- 'pil = large_image_source_pil:PILFileTileSource'
69
+ 'pil = large_image_source_pil:PILFileTileSource',
70
70
  ],
71
71
  'girder_large_image.source': [
72
- 'pil = large_image_source_pil.girder_source:PILGirderTileSource'
73
- ]
72
+ 'pil = large_image_source_pil.girder_source:PILGirderTileSource',
73
+ ],
74
74
  },
75
75
  )