large-image-source-test 1.23.3.dev62__tar.gz → 1.23.3.dev65__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {large-image-source-test-1.23.3.dev62 → large-image-source-test-1.23.3.dev65}/PKG-INFO +1 -1
- {large-image-source-test-1.23.3.dev62 → large-image-source-test-1.23.3.dev65}/large_image_source_test/__init__.py +16 -15
- {large-image-source-test-1.23.3.dev62 → large-image-source-test-1.23.3.dev65}/large_image_source_test.egg-info/PKG-INFO +1 -1
- {large-image-source-test-1.23.3.dev62 → large-image-source-test-1.23.3.dev65}/large_image_source_test.egg-info/requires.txt +1 -1
- {large-image-source-test-1.23.3.dev62 → large-image-source-test-1.23.3.dev65}/setup.py +3 -3
- {large-image-source-test-1.23.3.dev62 → large-image-source-test-1.23.3.dev65}/LICENSE +0 -0
- {large-image-source-test-1.23.3.dev62 → large-image-source-test-1.23.3.dev65}/README.rst +0 -0
- {large-image-source-test-1.23.3.dev62 → large-image-source-test-1.23.3.dev65}/large_image_source_test.egg-info/SOURCES.txt +0 -0
- {large-image-source-test-1.23.3.dev62 → large-image-source-test-1.23.3.dev65}/large_image_source_test.egg-info/dependency_links.txt +0 -0
- {large-image-source-test-1.23.3.dev62 → large-image-source-test-1.23.3.dev65}/large_image_source_test.egg-info/entry_points.txt +0 -0
- {large-image-source-test-1.23.3.dev62 → large-image-source-test-1.23.3.dev65}/large_image_source_test.egg-info/top_level.txt +0 -0
- {large-image-source-test-1.23.3.dev62 → large-image-source-test-1.23.3.dev65}/setup.cfg +0 -0
@@ -19,7 +19,7 @@ import itertools
|
|
19
19
|
import math
|
20
20
|
import re
|
21
21
|
|
22
|
-
import numpy
|
22
|
+
import numpy as np
|
23
23
|
from PIL import Image, ImageDraw, ImageFont
|
24
24
|
|
25
25
|
from large_image.cache_util import LruCacheMetaclass, methodcache, strhash
|
@@ -42,7 +42,7 @@ except PackageNotFoundError:
|
|
42
42
|
|
43
43
|
|
44
44
|
_counters = {
|
45
|
-
'tiles': 0
|
45
|
+
'tiles': 0,
|
46
46
|
}
|
47
47
|
|
48
48
|
|
@@ -50,7 +50,7 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
|
|
50
50
|
cacheName = 'tilesource'
|
51
51
|
name = 'test'
|
52
52
|
extensions = {
|
53
|
-
None: SourcePriority.MANUAL
|
53
|
+
None: SourcePriority.MANUAL,
|
54
54
|
}
|
55
55
|
|
56
56
|
def __init__(self, ignored_path=None, minLevel=0, maxLevel=9,
|
@@ -110,7 +110,7 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
|
|
110
110
|
self.minLevel = min(self.minLevel, self.maxLevel)
|
111
111
|
self.monochrome = bool(monochrome)
|
112
112
|
self._bands = None
|
113
|
-
self._dtype =
|
113
|
+
self._dtype = np.uint8
|
114
114
|
if bands:
|
115
115
|
bands = [re.match(
|
116
116
|
r'^(?P<key>[^=]+)(|=(?P<low>[+-]?((\d+(|\.\d*)))|(\.\d+))-(?P<high>[+-]?((\d+(|\.\d*))|(\.\d+))))$', # noqa
|
@@ -134,7 +134,7 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
|
|
134
134
|
if low < 0 or high < 2 or low >= 65536 or high >= 65536:
|
135
135
|
self._dtype = float
|
136
136
|
elif low >= 256 or high >= 256:
|
137
|
-
self._dtype =
|
137
|
+
self._dtype = np.uint16
|
138
138
|
# Used for reporting tile information
|
139
139
|
self.levels = self.maxLevel + 1
|
140
140
|
if frames:
|
@@ -226,7 +226,7 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
|
|
226
226
|
image = Image.new(
|
227
227
|
mode='RGB',
|
228
228
|
size=(self.tileWidth, self.tileHeight),
|
229
|
-
color=(rgbColor if not self.fractal else (255, 255, 255))
|
229
|
+
color=(rgbColor if not self.fractal else (255, 255, 255)),
|
230
230
|
)
|
231
231
|
if self.fractal:
|
232
232
|
self.fractalTile(image, x, y, 2 ** z, rgbColor)
|
@@ -236,17 +236,17 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
|
|
236
236
|
'r', 'red', 'g', 'green', 'b', 'blue', 'grey', 'gray', 'alpha'}:
|
237
237
|
bandtext += band
|
238
238
|
image = _imageToNumpy(image)[0].astype(float)
|
239
|
-
vstripe =
|
239
|
+
vstripe = np.array([
|
240
240
|
int(x / (self.tileWidth / bandnum / 2)) % 2
|
241
241
|
for x in range(self.tileWidth)])
|
242
|
-
hstripe =
|
242
|
+
hstripe = np.array([
|
243
243
|
int(y / (self.tileHeight / (bandnum % self.tileWidth) / 2)) % 2
|
244
244
|
if bandnum > self.tileWidth else 1 for y in range(self.tileHeight)])
|
245
245
|
simage = image.copy()
|
246
246
|
simage[hstripe == 0, :, :] /= 2
|
247
247
|
simage[:, vstripe == 0, :] /= 2
|
248
|
-
image =
|
249
|
-
image = image.astype(
|
248
|
+
image = np.where(image != 255, simage, image)
|
249
|
+
image = image.astype(np.uint8)
|
250
250
|
image = _imageToPIL(image)
|
251
251
|
|
252
252
|
imageDraw = ImageDraw.Draw(image)
|
@@ -263,7 +263,7 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
|
|
263
263
|
# the font size should fill the whole tile
|
264
264
|
imageDrawFont = ImageFont.truetype(
|
265
265
|
font='/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf',
|
266
|
-
size=int(fontsize * min(self.tileWidth, self.tileHeight))
|
266
|
+
size=int(fontsize * min(self.tileWidth, self.tileHeight)),
|
267
267
|
)
|
268
268
|
except OSError:
|
269
269
|
imageDrawFont = ImageFont.load_default()
|
@@ -271,7 +271,7 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
|
|
271
271
|
xy=(10, 10),
|
272
272
|
text=text,
|
273
273
|
fill=(0, 0, 0) if band != 'alpha' else (255, 255, 255),
|
274
|
-
font=imageDrawFont
|
274
|
+
font=imageDrawFont,
|
275
275
|
)
|
276
276
|
return image
|
277
277
|
|
@@ -281,7 +281,8 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
|
|
281
281
|
self._xyzInRange(x, y, z, frame, len(self._frames) if hasattr(self, '_frames') else None)
|
282
282
|
|
283
283
|
if not (self.minLevel <= z <= self.maxLevel):
|
284
|
-
|
284
|
+
msg = 'z layer does not exist'
|
285
|
+
raise TileSourceError(msg)
|
285
286
|
_counters['tiles'] += 1
|
286
287
|
|
287
288
|
xFraction = (x + 0.5) * self.tileWidth * 2 ** (self.levels - 1 - z) / self.sizeX
|
@@ -303,14 +304,14 @@ class TestTileSource(TileSource, metaclass=LruCacheMetaclass):
|
|
303
304
|
image = image.convert('L')
|
304
305
|
format = TILE_FORMAT_PIL
|
305
306
|
else:
|
306
|
-
image =
|
307
|
+
image = np.zeros(
|
307
308
|
(self.tileHeight, self.tileWidth, len(self._bands)), dtype=self._dtype)
|
308
309
|
for bandnum, band in enumerate(self._bands):
|
309
310
|
bandimg = self._tileImage(rgbColor, x, y, z, frame, band, bandnum)
|
310
311
|
if self.monochrome or band.upper() in {'grey', 'gray', 'alpha'}:
|
311
312
|
bandimg = bandimg.convert('L')
|
312
313
|
bandimg = _imageToNumpy(bandimg)[0]
|
313
|
-
if (self._dtype !=
|
314
|
+
if (self._dtype != np.uint8 or
|
314
315
|
self._bands[band]['low'] != 0 or
|
315
316
|
self._bands[band]['high'] != 255):
|
316
317
|
bandimg = bandimg.astype(float)
|
@@ -62,10 +62,10 @@ setup(
|
|
62
62
|
python_requires='>=3.6',
|
63
63
|
entry_points={
|
64
64
|
'large_image.source': [
|
65
|
-
'test = large_image_source_test:TestTileSource'
|
65
|
+
'test = large_image_source_test:TestTileSource',
|
66
66
|
],
|
67
67
|
'girder_large_image.source': [
|
68
|
-
'test = large_image_source_test:TestTileSource'
|
69
|
-
]
|
68
|
+
'test = large_image_source_test:TestTileSource',
|
69
|
+
],
|
70
70
|
},
|
71
71
|
)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|