async-tiff 0.4.0__cp310-cp310-macosx_11_0_arm64.whl → 0.5.0b4__cp310-cp310-macosx_11_0_arm64.whl

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.
async_tiff/__init__.py CHANGED
@@ -1,8 +1,8 @@
1
- from typing import TYPE_CHECKING
2
-
1
+ from . import enums
3
2
  from ._async_tiff import (
4
3
  TIFF,
5
4
  Array,
5
+ Colormap,
6
6
  DecoderRegistry,
7
7
  GeoKeyDirectory,
8
8
  ImageFileDirectory,
@@ -13,14 +13,12 @@ from ._async_tiff import (
13
13
  from ._decoder_runtime import Decoder
14
14
  from ._input import ObspecInput
15
15
 
16
- if TYPE_CHECKING:
17
- from . import store
18
-
19
16
  __version__: str = ___version()
20
17
 
21
18
  __all__ = [
22
- "store",
19
+ "enums",
23
20
  "Array",
21
+ "Colormap",
24
22
  "Decoder",
25
23
  "DecoderRegistry",
26
24
  "GeoKeyDirectory",
async_tiff/_array.pyi CHANGED
@@ -1,4 +1,9 @@
1
- from collections.abc import Buffer
1
+ import sys
2
+
3
+ if sys.version_info >= (3, 12):
4
+ from collections.abc import Buffer
5
+ else:
6
+ from typing_extensions import Buffer
2
7
 
3
8
  class Array(Buffer):
4
9
  """A 3D array that implements Python's buffer protocol.
@@ -1,4 +1,5 @@
1
1
  from ._array import Array
2
+ from ._colormap import Colormap
2
3
  from ._decoder import DecoderRegistry
3
4
  from ._geo import GeoKeyDirectory
4
5
  from ._ifd import ImageFileDirectory
@@ -8,6 +9,7 @@ from ._tile import Tile
8
9
 
9
10
  __all__ = [
10
11
  "Array",
12
+ "Colormap",
11
13
  "DecoderRegistry",
12
14
  "GeoKeyDirectory",
13
15
  "ImageFileDirectory",
@@ -0,0 +1,14 @@
1
+ import sys
2
+
3
+ if sys.version_info >= (3, 12):
4
+ from collections.abc import Buffer
5
+ else:
6
+ from typing_extensions import Buffer
7
+
8
+ class Colormap(Buffer):
9
+ """A 1D array of u16 values representing a TIFF colormap.
10
+
11
+ Implements Python's buffer protocol for zero-copy access via `np.asarray()`.
12
+ """
13
+ def __buffer__(self, flags: int) -> memoryview[int]: ...
14
+ def __len__(self) -> int: ...
async_tiff/_decoder.pyi CHANGED
@@ -1,10 +1,10 @@
1
1
  from ._decoder_runtime import Decoder
2
- from .enums import CompressionMethod
2
+ from .enums import Compression
3
3
 
4
4
  class DecoderRegistry:
5
5
  """A registry holding multiple decoder methods."""
6
6
  def __init__(
7
- self, custom_decoders: dict[CompressionMethod | int, Decoder] | None = None
7
+ self, custom_decoders: dict[Compression | int, Decoder] | None = None
8
8
  ) -> None:
9
9
  """Construct a new decoder registry.
10
10
 
async_tiff/_ifd.pyi CHANGED
@@ -1,9 +1,11 @@
1
- from collections.abc import Iterable
1
+ from collections.abc import Iterable, Sequence
2
2
  from typing import Any
3
3
 
4
+ from ._colormap import Colormap
4
5
  from ._geo import GeoKeyDirectory
6
+ from ._tile import Tile
5
7
  from .enums import (
6
- CompressionMethod,
8
+ Compression,
7
9
  PhotometricInterpretation,
8
10
  PlanarConfiguration,
9
11
  Predictor,
@@ -35,11 +37,11 @@ class ImageFileDirectory:
35
37
  @property
36
38
  def bits_per_sample(self) -> list[int]: ...
37
39
  @property
38
- def compression(self) -> CompressionMethod | int:
40
+ def compression(self) -> Compression | int:
39
41
  """Access the compression tag.
40
42
 
41
43
  An `int` will be returned if the compression is not one of the values in
42
- `CompressionMethod`.
44
+ `Compression`.
43
45
  """
44
46
  @property
45
47
  def photometric_interpretation(self) -> PhotometricInterpretation: ...
@@ -122,3 +124,26 @@ class ImageFileDirectory:
122
124
  def gdal_metadata(self) -> str | None: ...
123
125
  @property
124
126
  def other_tags(self) -> dict[int, Value]: ...
127
+ @property
128
+ def colormap(self) -> Colormap | None:
129
+ """The colormap for palette-color images."""
130
+ ...
131
+ async def fetch_tile(self, x: int, y: int) -> Tile:
132
+ """Fetch a single tile.
133
+
134
+ Args:
135
+ x: The column index within the ifd to read from.
136
+ y: The row index within the ifd to read from.
137
+
138
+ Returns:
139
+ Tile response.
140
+ """
141
+ async def fetch_tiles(self, xy: Sequence[tuple[int, int]]) -> list[Tile]:
142
+ """Fetch multiple tiles concurrently.
143
+
144
+ Args:
145
+ xy: The (column, row) indexes within the ifd to read from.
146
+
147
+ Returns:
148
+ Tile responses.
149
+ """
async_tiff/_input.py CHANGED
@@ -1,8 +1,11 @@
1
1
  from typing import Protocol
2
2
 
3
- # Fix exports
4
- from obspec._get import GetRangeAsync, GetRangesAsync
3
+ from obspec import GetRangeAsync, GetRangesAsync
5
4
 
6
5
 
7
6
  class ObspecInput(GetRangeAsync, GetRangesAsync, Protocol):
8
- """Supported obspec input to reader."""
7
+ """Supported obspec input to reader.
8
+
9
+ Anything that implements [GetRangeAsync][obspec.GetRangeAsync] and
10
+ [GetRangesAsync][obspec.GetRangesAsync] can be used as an input to the TIFF reader.
11
+ """
async_tiff/_tiff.pyi CHANGED
@@ -1,3 +1,5 @@
1
+ from typing import Sequence
2
+
1
3
  from ._ifd import ImageFileDirectory
2
4
  from ._input import ObspecInput
3
5
  from ._tile import Tile
@@ -32,6 +34,17 @@ class TIFF:
32
34
  @property
33
35
  def endianness(self) -> Endianness:
34
36
  """The endianness of this TIFF file."""
37
+
38
+ def ifd(self, index: int) -> ImageFileDirectory:
39
+ """Access a specific IFD by index.
40
+
41
+ Args:
42
+ index: The IFD index to access.
43
+
44
+ Returns:
45
+ The requested IFD.
46
+ """
47
+
35
48
  @property
36
49
  def ifds(self) -> list[ImageFileDirectory]:
37
50
  """Access the underlying IFDs of this TIFF.
@@ -50,12 +63,11 @@ class TIFF:
50
63
  Returns:
51
64
  Tile response.
52
65
  """
53
- async def fetch_tiles(self, x: list[int], y: list[int], z: int) -> list[Tile]:
66
+ async def fetch_tiles(self, xy: Sequence[tuple[int, int]], z: int) -> list[Tile]:
54
67
  """Fetch multiple tiles concurrently.
55
68
 
56
69
  Args:
57
- x: The column indexes within the ifd to read from.
58
- y: The row indexes within the ifd to read from.
70
+ xy: The (column, row) indexes within the ifd to read from.
59
71
  z: The IFD index to read from.
60
72
 
61
73
  Returns:
async_tiff/_tile.pyi CHANGED
@@ -3,7 +3,7 @@ from collections.abc import Buffer
3
3
  from ._array import Array
4
4
  from ._decoder import DecoderRegistry
5
5
  from ._thread_pool import ThreadPool
6
- from .enums import CompressionMethod
6
+ from .enums import Compression
7
7
 
8
8
  class Tile:
9
9
  """A representation of a TIFF image tile."""
@@ -17,7 +17,7 @@ class Tile:
17
17
  def compressed_bytes(self) -> Buffer:
18
18
  """The compressed bytes underlying this tile."""
19
19
  @property
20
- def compression_method(self) -> CompressionMethod | int:
20
+ def compression_method(self) -> Compression | int:
21
21
  """The compression method used by this tile."""
22
22
  def decode_sync(
23
23
  self,
async_tiff/enums.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from enum import IntEnum
2
2
 
3
3
 
4
- class CompressionMethod(IntEnum):
4
+ class Compression(IntEnum):
5
5
  """
6
6
  See [TIFF compression
7
7
  tags](https://www.awaresystems.be/imaging/tiff/tifftags/compression.html) for
@@ -19,6 +19,10 @@ class CompressionMethod(IntEnum):
19
19
  Deflate = 8
20
20
  OldDeflate = 0x80B2
21
21
  PackBits = 0x8005
22
+ WebP = 50001
23
+ LZMA = 34925
24
+ JPEG2k = 34712
25
+ ZSTD = 0xC350
22
26
 
23
27
 
24
28
  class Endianness(IntEnum):
@@ -0,0 +1,103 @@
1
+ Metadata-Version: 2.4
2
+ Name: async-tiff
3
+ Version: 0.5.0b4
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ Requires-Dist: obspec>=0.1.0
8
+ Requires-Python: >=3.10
9
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
10
+
11
+ # async-tiff
12
+
13
+ [![PyPI][pypi_badge]][pypi_link]
14
+
15
+ [pypi_badge]: https://badge.fury.io/py/async-tiff.svg
16
+ [pypi_link]: https://pypi.org/project/async-tiff/
17
+
18
+ Fast, low-level async TIFF reader for Python.
19
+
20
+ This documentation is for the Python bindings. [Refer here for the Rust crate documentation](https://docs.rs/async-tiff).
21
+
22
+ For a higher-level API to read GeoTIFF files, visit [`async-geotiff`][async-geotiff].
23
+
24
+ [async-geotiff]: https://developmentseed.org/async-geotiff
25
+
26
+ ## Examples
27
+
28
+ ### Reading NAIP
29
+
30
+ ```py
31
+ from async_tiff import TIFF
32
+ from async_tiff.store import S3Store
33
+
34
+ # You'll also need to provide credentials to access a requester pays bucket
35
+ store = S3Store("naip-visualization", region="us-west-2", request_payer=True)
36
+ path = "ny/2022/60cm/rgb/40073/m_4007307_sw_18_060_20220803.tif"
37
+
38
+ tiff = await TIFF.open(path, store=store)
39
+ primary_ifd = tiff.ifds[0]
40
+
41
+ primary_ifd.geo_key_directory.citation
42
+ # 'NAD83 / UTM zone 18N'
43
+
44
+ primary_ifd.geo_key_directory.projected_type
45
+ # 26918
46
+ # (EPSG code)
47
+
48
+ primary_ifd.sample_format
49
+ # [<SampleFormat.Uint: 1>, <SampleFormat.Uint: 1>, <SampleFormat.Uint: 1>]
50
+
51
+ primary_ifd.bits_per_sample
52
+ # [8, 8, 8]
53
+
54
+ tile = await tiff.fetch_tile(0, 0, 4)
55
+ array = await tile.decode()
56
+
57
+ # Use rasterio and matplotlib for visualization
58
+ import numpy as np
59
+ from rasterio.plot import reshape_as_raster, show
60
+
61
+ # Zero-copy conversion of the rust array into a numpy array
62
+ np_array = np.asarray(array)
63
+
64
+ # Then we need to reshape the "image" axes into "raster" axes
65
+ # https://rasterio.readthedocs.io/en/stable/topics/image_processing.html
66
+ show(reshape_as_raster(np_array), adjust=True)
67
+ ```
68
+
69
+ ![](assets/naip-example.jpg)
70
+
71
+
72
+ ### Reading Sentinel 2 L2A
73
+
74
+ ```py
75
+ import numpy as np
76
+ from async_tiff import TIFF
77
+ from async_tiff.store import S3Store
78
+
79
+ store = S3Store("sentinel-cogs", region="us-west-2", skip_signature=True)
80
+ path = "sentinel-s2-l2a-cogs/12/S/UF/2022/6/S2B_12SUF_20220609_0_L2A/B04.tif"
81
+
82
+ tiff = await TIFF.open(path, store=store)
83
+ primary_ifd = tiff.ifds[0]
84
+ # Text readable citation
85
+ primary_ifd.geo_key_directory.citation
86
+ # EPSG code
87
+ primary_ifd.geo_key_directory.projected_type
88
+
89
+ primary_ifd.sample_format[0]
90
+ # <SampleFormat.Uint: 1>
91
+ primary_ifd.bits_per_sample[0]
92
+ # 16
93
+
94
+ tile = await tiff.fetch_tile(0, 0, 0)
95
+ array = await tile.decode()
96
+
97
+ # Zero-copy conversion of the rust array into a numpy array
98
+ np_array = np.asarray(array)
99
+ np_array.shape
100
+ # (1024, 1024, 1)
101
+ ```
102
+
103
+
@@ -0,0 +1,18 @@
1
+ async_tiff/__init__.py,sha256=gdLgfl7BLntXTceX9JdojgOwy_8sH7-YuEuQedBr3o4,559
2
+ async_tiff/_array.pyi,sha256=muitV2BmObMPBF1O1mgo9a89posx7-ubsl4XftG5WO4,1257
3
+ async_tiff/_async_tiff.cpython-310-darwin.so,sha256=dd82Uy38oDZZ4yMURNiWE2NesTq0UgTM-zmtYDyTbqo,7960256
4
+ async_tiff/_async_tiff.pyi,sha256=I0Z9ey5GYZYfjJB4ZEyPUzHTsw0GcA5KBrAbTiThMc8,410
5
+ async_tiff/_colormap.pyi,sha256=NrXLqUq3U81bI0zG8OLgQwv_JM0YS-MrVgx-1nD6j3g,402
6
+ async_tiff/_decoder.pyi,sha256=tRHzZbZj1V6lDireFpNQ-f2h2tPFqh2ExYu4L6v0Cqc,709
7
+ async_tiff/_decoder_runtime.py,sha256=N2IC7XTgC1TmGmB7ZXCJbrVVSbn6G85cWgJ6k87XpT8,553
8
+ async_tiff/_geo.pyi,sha256=h71Y9zZ5vYxXaXAR4QAYmBJ0FOhLfXMMJA85p474eTE,3451
9
+ async_tiff/_ifd.pyi,sha256=zjU_fENQr8roZMyTFRJpClLzOpHJHHeNhO--iN0XwMA,4698
10
+ async_tiff/_input.py,sha256=CXgxr2kCxmKWQ3Ev3Jud6N5R1Vpl1r4YXpnr7485c8U,349
11
+ async_tiff/_thread_pool.pyi,sha256=fbDu9kbo8RNlq7bBBxuuu_6ub20L5cAfXBM-J7Y0PC8,181
12
+ async_tiff/_tiff.pyi,sha256=-TSMH4-k6moaDE1zoXPDkzGF1xLfd_1DzYMzAcALVu0,2178
13
+ async_tiff/_tile.pyi,sha256=NBUciMH6nan6qQLt30p9msUiY4BKh4ZmW4r9CsqtYho,1961
14
+ async_tiff/enums.py,sha256=81S3s7eKtCgxuLxuI2pw5K_43S7I3wJ8m7LRpKAzj_I,1047
15
+ async_tiff/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ async_tiff-0.5.0b4.dist-info/METADATA,sha256=HP-ILZqvAvK-1GAhkTTnzw1Qyq17dZfdJ1-lgpYiX8Q,2741
17
+ async_tiff-0.5.0b4.dist-info/WHEEL,sha256=lgXxQDOXaD3ZlhS7NozX7pozuWR_5xphTDPgxH3-aMg,105
18
+ async_tiff-0.5.0b4.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: async-tiff
3
- Version: 0.4.0
4
- Classifier: Programming Language :: Rust
5
- Classifier: Programming Language :: Python :: Implementation :: CPython
6
- Classifier: Programming Language :: Python :: Implementation :: PyPy
7
- Requires-Dist: obspec>=0.1.0
8
- Requires-Python: >=3.10
@@ -1,17 +0,0 @@
1
- async_tiff/__init__.py,sha256=EAs0ZXh393JFZeO_mpt69rDHQdv-cnZkU4rgqvUGf7A,586
2
- async_tiff/_array.pyi,sha256=uuJLjpoGF6wk_VS4kfTJIS_mhQ29RBEYGyy40cn5E28,1162
3
- async_tiff/_async_tiff.cpython-310-darwin.so,sha256=ndWyZq848BbonNICtai-J3g2eLD6hYUOrq41BKhw1yA,7679248
4
- async_tiff/_async_tiff.pyi,sha256=9Jbj2DFNpmo4BqBUU9p9-Z-8Ea_warzn-LPE2m3SzBM,362
5
- async_tiff/_decoder.pyi,sha256=T1600oX7eWwzulo3uxWvqZ0CFwcMgQ_iAA7NzaQc5Hg,721
6
- async_tiff/_decoder_runtime.py,sha256=N2IC7XTgC1TmGmB7ZXCJbrVVSbn6G85cWgJ6k87XpT8,553
7
- async_tiff/_geo.pyi,sha256=h71Y9zZ5vYxXaXAR4QAYmBJ0FOhLfXMMJA85p474eTE,3451
8
- async_tiff/_ifd.pyi,sha256=X6eAFIc6jBIR9nnLnjQFNVFnQ6fr9zoUJeQjZAdv494,3981
9
- async_tiff/_input.py,sha256=f6FCam4uyKaWXy-npUQ-nePaXeOsWMdXt2WcyH5fhq0,203
10
- async_tiff/_thread_pool.pyi,sha256=fbDu9kbo8RNlq7bBBxuuu_6ub20L5cAfXBM-J7Y0PC8,181
11
- async_tiff/_tiff.pyi,sha256=aR7qtsfKBqYcdF-Jf6weZl9CE1owM9GgXu5gU2nAlIo,1980
12
- async_tiff/_tile.pyi,sha256=1JlhrXGq4xB9gbSrmMt4aUR5Bufr1LhFCFwOCdgf5X8,1973
13
- async_tiff/enums.py,sha256=uz6EUnLeLpbtD40vxXsd4VnFNQBMaC_o5bslqF8gJv0,982
14
- async_tiff/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
- async_tiff-0.4.0.dist-info/METADATA,sha256=2Hkh524tDGJ0nOYlHcFnyMcMgKvSQFoS9C-39cl-Ma0,289
16
- async_tiff-0.4.0.dist-info/WHEEL,sha256=lgXxQDOXaD3ZlhS7NozX7pozuWR_5xphTDPgxH3-aMg,105
17
- async_tiff-0.4.0.dist-info/RECORD,,