Glymur 0.13.1__py3-none-any.whl → 0.13.2__py3-none-any.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.
@@ -1,12 +1,11 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Glymur
3
- Version: 0.13.1
3
+ Version: 0.13.2
4
4
  Home-page: https://github.com/quintusdias/glymur
5
5
  Author: 'John Evans'
6
6
  Author-email: "John Evans" <jevans667cc@proton.me>
7
7
  License: 'MIT'
8
8
  Classifier: Programming Language :: Python
9
- Classifier: Programming Language :: Python :: 3.9
10
9
  Classifier: Programming Language :: Python :: 3.10
11
10
  Classifier: Programming Language :: Python :: 3.11
12
11
  Classifier: Programming Language :: Python :: 3.12
@@ -0,0 +1,25 @@
1
+ glymur/__init__.py,sha256=k14IfdaYuTWXSpAIDR3LVDtXt9XKjr-ZSNXCyu8pQko,586
2
+ glymur/_iccprofile.py,sha256=_WfQsT-BqEWQzQVTtuY7tSXqPjOtwvWGW36rKxlLv1s,4148
3
+ glymur/codestream.py,sha256=SEAudOSnGT1yWz-zDeIvDPmr7T1Gqhwc0tfErCHOBQw,60028
4
+ glymur/command_line.py,sha256=jm-6dD2jcU_G7mJAJ0U5sanfG9kRy-j0-G3eSN_Ieek,7476
5
+ glymur/config.py,sha256=ceGulS8TN2OYiTPtq3mAdhXrCCRlxjuLmvN_UG0009Y,4139
6
+ glymur/core.py,sha256=IDkk8FESyukQTB10LHBZ4VQM36NwKE4CXCcuJ407Kzg,3638
7
+ glymur/jp2box.py,sha256=bRzsq3UtZDVkM-_swwAdieSNZM7RsIE4tRNvOM1vnVo,112391
8
+ glymur/jp2k.py,sha256=TfHsP6ozMCKFcP26r_ouHw-GVD3OY_UChAh-EAJsKD4,54555
9
+ glymur/jp2kr.py,sha256=Jju0hNfLane24wqR8amQqiSR1qSNCxNydVC8FXQMOFQ,31497
10
+ glymur/options.py,sha256=Y777g4wpxPqRAF8s963goeAIogfLqIe_Dyd9f77MfmU,4428
11
+ glymur/tiff.py,sha256=2uoKfyoyPQWAsdPWB0IxW_npqpP4O10qVADQZf10jXs,41115
12
+ glymur/version.py,sha256=cZkWxcbr-Q_AtvUzLgMC56iNcQlSQAlxP7cAdc_gDMQ,981
13
+ glymur/data/__init__.py,sha256=n2KZrHV15it7Wu4YCaBLXui1ZleQ30dnZ92dyP6q05k,955
14
+ glymur/data/goodstuff.j2k,sha256=xKQG68KMu33gYjRUDTQvam1Cue2tdio85rNp5J-rYZE,115220
15
+ glymur/data/heliov.jpx,sha256=KXnYdBZgl25jcGLu-m-QfhuP9pqUXV0Hp9HHEdJqr34,1399071
16
+ glymur/data/nemo.jp2,sha256=yJ1NkTEwU0B_gBtAiA1c5hxtGYSJtJgq6cHC2IHpj70,1132373
17
+ glymur/lib/__init__.py,sha256=JnM9oPfcZhBDLKo7_yLS-lIRQ1wXb1N9hKKQ-G7vYVk,127
18
+ glymur/lib/openjp2.py,sha256=VHCy_TnBSDqQ8YlIQHkyFqUXOQ2E5C3jxJoziG73s0I,45052
19
+ glymur/lib/tiff.py,sha256=2o29IzYTsprVR_C6VDNHOzqk_U7aUdCoLQ2fjiyyoaI,50777
20
+ Glymur-0.13.2.dist-info/LICENSE.txt,sha256=G9pvBgkJdPTtZqQmoRyIgAydtic1ZwWtOWBea9VMW7I,1077
21
+ Glymur-0.13.2.dist-info/METADATA,sha256=PDbSJZb5dVVoi8a2wYuFW2-Sr_4RK6teOaaQBcvQ7mM,1020
22
+ Glymur-0.13.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
23
+ Glymur-0.13.2.dist-info/entry_points.txt,sha256=inzxpDbDDfIxtdXpCncAHdAdwJfjtXt3xKvIOsuZsG8,93
24
+ Glymur-0.13.2.dist-info/top_level.txt,sha256=D0SvtBUoPxOs40OTRW3l-kjGFHM6VrXS8yZPK5Fx2wY,7
25
+ Glymur-0.13.2.dist-info/RECORD,,
glymur/codestream.py CHANGED
@@ -951,8 +951,8 @@ class COCsegment(Segment):
951
951
  Coding style for this component.
952
952
  spcoc : byte array
953
953
  Coding style parameters for this component.
954
- precinct_size : list of tuples
955
- Dimensions of precinct.
954
+ precinct_size : nx2 array
955
+ Dimensions of precincts.
956
956
 
957
957
  References
958
958
  ----------
@@ -971,7 +971,7 @@ class COCsegment(Segment):
971
971
  if len(self.spcoc) > 5:
972
972
  self.precinct_size = _parse_precinct_size(self.spcoc[5:])
973
973
  else:
974
- self.precinct_size = ((32768, 32768))
974
+ self.precinct_size = np.array(((32768, 32768)))
975
975
 
976
976
  self.length = length
977
977
  self.offset = offset
@@ -993,7 +993,7 @@ class COCsegment(Segment):
993
993
  f' Number of decomposition levels: {self.spcoc[0]}\n'
994
994
  f' Code block height, width: ({width} x {height})\n'
995
995
  f' Wavelet transform: {xform}\n'
996
- f' Precinct size: {self.precinct_size}\n'
996
+ f' Precinct size: {self.precinct_size.tolist()}\n'
997
997
  f' {_context_string(self.spcoc[3])}'
998
998
  )
999
999
 
@@ -1028,8 +1028,8 @@ class CODsegment(Segment):
1028
1028
  Wavelet transform used
1029
1029
  cstyle : int
1030
1030
  Style of the code-block passes
1031
- precinct_size : list
1032
- 2-tuples of precinct sizes.
1031
+ precinct_size : nx2 array
1032
+ Array of precinct sizes.
1033
1033
 
1034
1034
  References
1035
1035
  ----------
@@ -1071,9 +1071,9 @@ class CODsegment(Segment):
1071
1071
  self.code_block_size = 4 * 2 ** ycb, 4 * 2 ** xcb
1072
1072
 
1073
1073
  if precinct_size is None:
1074
- self.precinct_size = ((2 ** 15, 2 ** 15))
1074
+ self.precinct_size = np.array(((2 ** 15, 2 ** 15)))
1075
1075
  else:
1076
- self.precinct_size = precinct_size
1076
+ self.precinct_size = np.array(precinct_size)
1077
1077
 
1078
1078
  def __str__(self):
1079
1079
  msg = Segment.__str__(self)
@@ -1123,7 +1123,7 @@ class CODsegment(Segment):
1123
1123
  cbh=int(self.code_block_size[0]),
1124
1124
  cbw=int(self.code_block_size[1]),
1125
1125
  xform=xform,
1126
- precinct_size=self.precinct_size,
1126
+ precinct_size=self.precinct_size.tolist(),
1127
1127
  code_block_context=_context_string(self.cstyle)
1128
1128
  )
1129
1129
 
@@ -1898,7 +1898,7 @@ def _parse_precinct_size(spcod):
1898
1898
  ep2 = (item & 0xF0) >> 4
1899
1899
  ep1 = item & 0x0F
1900
1900
  precinct_size.append((2 ** ep1, 2 ** ep2))
1901
- return tuple(precinct_size)
1901
+ return np.array(precinct_size)
1902
1902
 
1903
1903
 
1904
1904
  def _context_string(context):
glymur/config.py CHANGED
@@ -57,13 +57,9 @@ def _determine_full_path(libname):
57
57
  if platform.system().startswith('CYGWIN'):
58
58
  g = pathlib.Path('/usr/bin').glob('cygopenjp2*.dll')
59
59
  try:
60
- path = list(g)[0]
60
+ return list(g)[0]
61
61
  except IndexError:
62
- # openjpeg possibly not installed
63
- pass
64
- else:
65
- if path.exists():
66
- return path
62
+ return None
67
63
 
68
64
  # No joy on config file and not Cygwin. Can ctypes find it anyway?
69
65
  path = find_library(libname)
@@ -132,12 +128,7 @@ def glymur_config(libname):
132
128
 
133
129
  loader = ctypes.windll.LoadLibrary if os.name == 'nt' else ctypes.CDLL
134
130
  try:
135
- opj_lib = loader(path)
136
- except TypeError:
137
- # This can happen on Windows. Apparently ctypes.windll.LoadLibrary
138
- # is no longer taking a WindowsPath
139
- path = str(path)
140
- opj_lib = loader(path)
131
+ opj_lib = loader(str(path))
141
132
  except OSError:
142
133
  msg = f'The {libname} library at {path} could not be loaded.'
143
134
  warnings.warn(msg, UserWarning)
glymur/data/__init__.py CHANGED
@@ -3,11 +3,10 @@
3
3
  These include:
4
4
  nemo.jp2: converted from the original JPEG photo of the aftermath of NEMO,
5
5
  the nor'easter that shutdown Boston in February of 2013.
6
- goodstuff.j2k: my favorite bevorage.
6
+ goodstuff.j2k: my favorite beverage.
7
7
 
8
8
  """
9
9
  import importlib.resources as ir
10
- import sys
11
10
 
12
11
 
13
12
  def nemo():
@@ -18,7 +17,7 @@ def nemo():
18
17
  file : str
19
18
  Platform-independent path to nemo.jp2.
20
19
  """
21
- return _str_path_to('nemo.jp2')
20
+ return str(ir.files('glymur.data').joinpath('nemo.jp2'))
22
21
 
23
22
 
24
23
  def goodstuff():
@@ -29,7 +28,7 @@ def goodstuff():
29
28
  file : str
30
29
  Platform-independent path to goodstuff.j2k.
31
30
  """
32
- return _str_path_to('goodstuff.j2k')
31
+ return str(ir.files('glymur.data').joinpath('goodstuff.j2k'))
33
32
 
34
33
 
35
34
  def jpxfile():
@@ -40,13 +39,4 @@ def jpxfile():
40
39
  file : str
41
40
  Platform-independent path to heliov.jpx
42
41
  """
43
- return _str_path_to('heliov.jpx')
44
-
45
-
46
- def _str_path_to(filename):
47
- """Hide differences between 3.9.0 and below."""
48
- if sys.version_info[1] >= 9:
49
- return str(ir.files('glymur.data').joinpath(filename))
50
- else:
51
- with ir.path('glymur.data', filename) as path:
52
- return str(path)
42
+ return str(ir.files('glymur.data').joinpath('heliov.jpx'))
glymur/jp2box.py CHANGED
@@ -28,7 +28,7 @@ import warnings
28
28
  try:
29
29
  from osgeo import gdal
30
30
  _HAVE_GDAL = True
31
- except (ImportError, ModuleNotFoundError):
31
+ except (ImportError, ModuleNotFoundError): # pragma: no cover
32
32
  _HAVE_GDAL = False
33
33
  else:
34
34
  gdal.UseExceptions()
@@ -1675,7 +1675,6 @@ class ImageHeaderBox(Jp2kBox):
1675
1675
  ):
1676
1676
  """Examples
1677
1677
  --------
1678
- >>> import glymur
1679
1678
  >>> box = glymur.jp2box.ImageHeaderBox(height=512, width=256)
1680
1679
  """
1681
1680
  super().__init__()
@@ -3510,11 +3509,8 @@ class UUIDBox(Jp2kBox):
3510
3509
  lst.append(text)
3511
3510
  elif self.uuid == _GEOTIFF_UUID:
3512
3511
 
3513
- if self.data is None:
3514
- return 'UUID Data: corrupt'
3515
-
3516
3512
  options = gdal.InfoOptions(showColorTable=False)
3517
- txt = gdal.Info(self._ftpr.name, options=options)
3513
+ txt = gdal.Info(self._fptr.name, options=options)
3518
3514
  txt = textwrap.indent(txt, ' ' * 4).rstrip()
3519
3515
 
3520
3516
  txt = f'UUID Data:\n{txt}'
@@ -3559,7 +3555,7 @@ class UUIDBox(Jp2kBox):
3559
3555
  the_uuid = UUID(bytes=read_buffer[0:16])
3560
3556
 
3561
3557
  o = cls(the_uuid, read_buffer[16:], length=length, offset=offset)
3562
- o._ftpr = fptr
3558
+ o._fptr = fptr
3563
3559
 
3564
3560
  return o
3565
3561
 
@@ -3608,7 +3604,7 @@ def decompose_resolution(value: Number) -> Tuple[int, int, int]:
3608
3604
  value:
3609
3605
  A number to be represented as a fraction.
3610
3606
  Returns:
3611
- A tuple of the form (numerator, denominator, exponent).
3607
+ A tuple of the form (exponent, numerator, denominator).
3612
3608
  """
3613
3609
  frac = Fraction(value)
3614
3610
  max_allowed_frac = Fraction(2**15 - 1)
glymur/jp2k.py CHANGED
@@ -107,7 +107,6 @@ class Jp2k(Jp2kr):
107
107
 
108
108
  Examples
109
109
  --------
110
- >>> import glymur
111
110
  >>> jfile = glymur.data.nemo()
112
111
  >>> jp2 = glymur.Jp2k(jfile)
113
112
  >>> jp2.shape
@@ -124,7 +123,6 @@ class Jp2k(Jp2kr):
124
123
 
125
124
  Make use of OpenJPEG's thread support
126
125
 
127
- >>> import glymur
128
126
  >>> import time
129
127
  >>> if glymur.version.openjpeg_version >= '2.2.0':
130
128
  ... jp2file = glymur.data.nemo()
@@ -229,6 +227,10 @@ class Jp2k(Jp2kr):
229
227
  # contained in memory.
230
228
  self[:] = data
231
229
 
230
+ def __repr__(self):
231
+ msg = f"glymur.Jp2k('{self.path}')"
232
+ return msg
233
+
232
234
  def finalize(self, force_parse=False):
233
235
  """For now, the only remaining tasks are to possibly parse the file
234
236
  and to possibly write out a ResolutionBox. There could be other
@@ -351,10 +353,6 @@ class Jp2k(Jp2kr):
351
353
  )
352
354
  raise RuntimeError(msg)
353
355
 
354
- def __repr__(self):
355
- msg = f"glymur.Jp2k('{self.path}')"
356
- return msg
357
-
358
356
  def get_tilewriters(self):
359
357
  """Return an object that facilitates writing tile by tile."""
360
358
 
@@ -805,11 +803,9 @@ class Jp2k(Jp2kr):
805
803
 
806
804
  Examples
807
805
  --------
808
- >>> import glymur, tempfile
809
806
  >>> jfile = glymur.data.goodstuff()
810
807
  >>> j2k = glymur.Jp2k(jfile)
811
- >>> tfile = tempfile.NamedTemporaryFile(suffix='jp2')
812
- >>> jp2 = j2k.wrap(tfile.name)
808
+ >>> jp2 = j2k.wrap('jp2_from_j2k.jp2')
813
809
  """
814
810
  if boxes is None:
815
811
  boxes = self._get_default_jp2_boxes()
glymur/jp2kr.py CHANGED
@@ -42,7 +42,6 @@ class Jp2kr(Jp2kBox):
42
42
 
43
43
  Examples
44
44
  --------
45
- >>> import glymur
46
45
  >>> jfile = glymur.data.nemo()
47
46
  >>> jp2 = glymur.Jp2kr(jfile)
48
47
  >>> jp2.shape
@@ -265,7 +264,7 @@ class Jp2kr(Jp2kBox):
265
264
  self._shape = shape
266
265
 
267
266
  def __repr__(self):
268
- msg = f"glymur.Jp2k('{self.path}')"
267
+ msg = f"glymur.Jp2kr('{self.path}')"
269
268
  return msg
270
269
 
271
270
  def __str__(self):
@@ -277,6 +276,7 @@ class Jp2kr(Jp2kBox):
277
276
  # No codestream either. Empty file? We are done.
278
277
  return metadata[0]
279
278
  else:
279
+ # Just a codestream, so J2K
280
280
  metadata.append(str(self.codestream))
281
281
  return '\n'.join(metadata)
282
282
 
@@ -419,9 +419,6 @@ class Jp2kr(Jp2kBox):
419
419
 
420
420
  def __getitem__(self, pargs):
421
421
  """Slicing protocol."""
422
- if not self.path.exists():
423
- msg = f"Cannot read from {self.filename}, it does not yet exist."
424
- raise FileNotFoundError(msg)
425
422
  if len(self.shape) == 2:
426
423
  numrows, numcols = self.shape
427
424
  numbands = 1
@@ -750,7 +747,6 @@ class Jp2kr(Jp2kBox):
750
747
 
751
748
  Examples
752
749
  --------
753
- >>> import glymur
754
750
  >>> jfile = glymur.data.nemo()
755
751
  >>> jp = glymur.Jp2k(jfile)
756
752
  >>> components_lst = jp.read_bands(rlevel=1)
@@ -878,12 +874,11 @@ class Jp2kr(Jp2kBox):
878
874
 
879
875
  Examples
880
876
  --------
881
- >>> import glymur
882
877
  >>> jfile = glymur.data.nemo()
883
878
  >>> jp2 = glymur.Jp2k(jfile)
884
879
  >>> codestream = jp2.get_codestream()
885
880
  >>> print(codestream.segment[1])
886
- SIZ marker segment @ (3233, 47)
881
+ SIZ marker segment @ (87, 47)
887
882
  Profile: no profile
888
883
  Reference Grid Height, Width: (1456 x 2592)
889
884
  Vertical, Horizontal Reference Grid Offset: (0 x 0)
glymur/lib/openjp2.py CHANGED
@@ -33,10 +33,7 @@ def version():
33
33
  return v.decode('utf-8')
34
34
 
35
35
 
36
- if OPENJP2 is not None:
37
- _MAJOR, _MINOR, _PATCH = [int(x) for x in version().split('.')]
38
- else:
39
- _MAJOR, _MINOR, _PATCH = 0, 0, 0
36
+ _MAJOR, _MINOR, _PATCH = [int(x) for x in version().split('.')]
40
37
 
41
38
  ERROR_MSG_LST = queue.Queue()
42
39
 
@@ -973,13 +970,15 @@ def encoder_set_extra_options(codec, plt=False, tlm=False):
973
970
  OPENJP2.opj_encoder_set_extra_options.argtypes = ARGTYPES
974
971
  OPENJP2.opj_encoder_set_extra_options.restype = check_error
975
972
 
973
+ # Send the library a null terminated array of char instructions. As of
974
+ # version 2.4.0, there is only a single instruction possible. As of 2.5.0,
975
+ # there are two possible instructions.
976
976
  arr = (ctypes.c_char_p * 3)()
977
+ arr[0] = arr[1] = arr[2] = None
978
+
977
979
  arr[0] = 'PLT=YES'.encode('utf-8') if plt else 'PLT=NO'.encode('utf-8')
978
980
  if version() >= '2.5.0':
979
981
  arr[1] = 'TLM=YES'.encode('utf-8') if tlm else 'TLM=NO'.encode('utf-8')
980
- arr[2] = None
981
- else:
982
- arr[1] = None
983
982
 
984
983
  OPENJP2.opj_encoder_set_extra_options(codec, arr)
985
984
 
glymur/lib/tiff.py CHANGED
@@ -119,41 +119,27 @@ class Photometric(IntEnum):
119
119
  this if you do not also specify YCbCr as the photometric interpretation.
120
120
 
121
121
  >>> w, h, nz = image.shape
122
- >>> from spiff import TIFF, lib
123
- >>> t = TIFF('astronaut-jpeg.tif', mode='w8')
124
- >>> t['Photometric'] = lib.Photometric.YCBCR
125
- >>> t['Compression'] = lib.Compression.JPEG
126
- >>> t['JPEGColorMode'] = lib.JPEGColorMode.RGB
127
- >>> t['PlanarConfig'] = lib.PlanarConfig.CONTIG
128
- >>> t['JPEGQuality'] = 90
129
- >>> t['YCbCrSubsampling'] = (1, 1)
130
- >>> t['ImageWidth'] = w
131
- >>> t['ImageLength'] = h
132
- >>> t['TileWidth'] = int(w/2)
133
- >>> t['TileLength'] = int(h/2)
134
- >>> t['BitsPerSample'] = 8
135
- >>> t['SamplesPerPixel'] = nz
136
- >>> t['Software'] = lib.getVersion()
137
- >>> t[:] = image
138
- >>> t
139
- TIFF Directory at offset 0x0 (0)
140
- Image Width: 512 Image Length: 512
141
- Tile Width: 256 Tile Length: 256
142
- Bits/Sample: 8
143
- Compression Scheme: JPEG
144
- Photometric Interpretation: YCbCr
145
- YCbCr Subsampling: 1, 1
146
- Samples/Pixel: 3
147
- Planar Configuration: single image plane
148
- Reference Black/White:
149
- 0: 0 255
150
- 1: 128 255
151
- 2: 128 255
152
- Software: LIBTIFF, Version 4.0.9
153
- Copyright (c) 1988-1996 Sam Leffler
154
- Copyright (c) 1991-1996 Silicon Graphics, Inc.
155
- JPEG Tables: (574 bytes)
156
- <BLANKLINE>
122
+ >>> tw, th = w // 2, h // 2
123
+ >>> from glymur.lib import tiff as libtiff
124
+ >>> fp = libtiff.open('astronaut-jpeg.tif', mode='w8')
125
+ >>> libtiff.setField(fp, 'Photometric', libtiff.Photometric.YCBCR)
126
+ >>> libtiff.setField(fp, 'Compression', libtiff.Compression.JPEG)
127
+ >>> libtiff.setField(fp, 'JPEGColorMode', libtiff.JPEGColorMode.RGB)
128
+ >>> libtiff.setField(fp, 'PlanarConfig', libtiff.PlanarConfig.CONTIG)
129
+ >>> libtiff.setField(fp, 'JPEGQuality', 90)
130
+ >>> libtiff.setField(fp, 'YCbCrSubsampling', 1, 1)
131
+ >>> libtiff.setField(fp, 'ImageWidth', w)
132
+ >>> libtiff.setField(fp, 'ImageLength', h)
133
+ >>> libtiff.setField(fp, 'TileWidth', tw)
134
+ >>> libtiff.setField(fp, 'TileLength', th)
135
+ >>> libtiff.setField(fp, 'BitsPerSample', 8)
136
+ >>> libtiff.setField(fp, 'SamplesPerPixel', nz)
137
+ >>> libtiff.setField(fp, 'Software', libtiff.getVersion())
138
+ >>> libtiff.writeEncodedTile(fp, 0, image[:th, :tw].copy())
139
+ >>> libtiff.writeEncodedTile(fp, 1, image[:th, tw:w].copy())
140
+ >>> libtiff.writeEncodedTile(fp, 2, image[th:h, :tw].copy())
141
+ >>> libtiff.writeEncodedTile(fp, 3, image[th:h, tw:w].copy())
142
+ >>> libtiff.close(fp)
157
143
  """
158
144
  MINISWHITE = 0 # value is white
159
145
  MINISBLACK = 1 # value is black
@@ -588,7 +574,7 @@ def setErrorHandler(func=_ERROR_HANDLER):
588
574
  return old_error_handler
589
575
 
590
576
 
591
- def setField(fp, tag, value):
577
+ def setField(fp, tag, *value):
592
578
  """Corresponds to TIFFSetField"""
593
579
  err_handler, warn_handler = _set_error_warning_handlers()
594
580
 
@@ -598,11 +584,21 @@ def setField(fp, tag, value):
598
584
  tag_num = TAGS[tag]['number']
599
585
  tag_type = TAGS[tag]['type']
600
586
 
601
- ARGTYPES.append(tag_type)
587
+ try:
588
+ for ttype in tag_type:
589
+ ARGTYPES.append(ttype)
590
+ except TypeError:
591
+ ARGTYPES.append(tag_type)
592
+
602
593
  _LIBTIFF.TIFFSetField.argtypes = ARGTYPES
603
594
  _LIBTIFF.TIFFSetField.restype = check_error
604
595
 
605
- _LIBTIFF.TIFFSetField(fp, tag_num, value)
596
+ if len(value) == 1 and tag_type == ctypes.c_char_p:
597
+ _LIBTIFF.TIFFSetField(fp, tag_num, ctypes.c_char_p(value[0].encode()))
598
+ elif len(value) == 1:
599
+ _LIBTIFF.TIFFSetField(fp, tag_num, value[0])
600
+ else:
601
+ _LIBTIFF.TIFFSetField(fp, tag_num, *value)
606
602
 
607
603
  _reset_error_warning_handlers(err_handler, warn_handler)
608
604
 
glymur/options.py CHANGED
@@ -57,6 +57,11 @@ def set_option(key, value):
57
57
  When False, printing of the XML contents of any XML boxes or UUID XMP
58
58
  boxes is suppressed. [default: True]
59
59
 
60
+ Examples
61
+ --------
62
+ >>> glymur.set_option('print.short', True)
63
+ >>> glymur.reset_option('all')
64
+
60
65
  See also
61
66
  --------
62
67
  get_option
@@ -132,83 +137,18 @@ def reset_option(key):
132
137
 
133
138
 
134
139
  def set_parseoptions(full_codestream=True):
135
- """Set parsing options.
136
-
137
- These options determine the way JPEG 2000 boxes are parsed.
138
-
139
- Parameters
140
- ----------
141
- full_codestream : bool, defaults to True
142
- When False, only the codestream header is parsed for metadata. This
143
- can results in faster JP2/JPX parsing. When True, the entire
144
- codestream is parsed for metadata.
145
-
146
- See also
147
- --------
148
- get_parseoptions
149
-
150
- Examples
151
- --------
152
- To put back the default options, you can use:
153
-
154
- >>> import glymur
155
- >>> glymur.set_parseoptions(full_codestream=True)
156
- """
157
140
  warnings.warn('Use set_option instead of set_parseoptions.',
158
141
  DeprecationWarning)
159
142
  set_option('parse.full_codestream', full_codestream)
160
143
 
161
144
 
162
145
  def get_parseoptions():
163
- """Return the current parsing options.
164
-
165
- Returns
166
- -------
167
- dict
168
- Dictionary of current print options with keys
169
-
170
- - codestream : bool
171
-
172
- For a full description of these options, see `set_parseoptions`.
173
-
174
- See also
175
- --------
176
- set_parseoptions
177
- """
178
146
  warnings.warn('Use set_option instead of set_parseoptions.',
179
147
  DeprecationWarning)
180
148
  return {'full_codestream': get_option('parse.full_codestream')}
181
149
 
182
150
 
183
151
  def set_printoptions(**kwargs):
184
- """Set printing options.
185
-
186
- These options determine the way JPEG 2000 boxes are displayed.
187
-
188
- Parameters
189
- ----------
190
- short : bool, optional
191
- When True, only the box ID, offset, and length are displayed. Useful
192
- for displaying only the basic structure or skeleton of a JPEG 2000
193
- file.
194
- xml : bool, optional
195
- When False, printing of the XML contents of any XML boxes or UUID XMP
196
- boxes is suppressed.
197
- codestream : bool, optional
198
- When False, the codestream segments are not printed. Otherwise the
199
- segments are printed depending on how set_parseoptions has been used.
200
-
201
- See also
202
- --------
203
- get_printoptions
204
-
205
- Examples
206
- --------
207
- To put back the default options, you can use:
208
-
209
- >>> import glymur
210
- >>> glymur.set_printoptions(short=False, xml=True, codestream=True)
211
- """
212
152
  warnings.warn('Use set_option instead of set_printoptions.',
213
153
  DeprecationWarning)
214
154
  for key, value in kwargs.items():
@@ -218,23 +158,6 @@ def set_printoptions(**kwargs):
218
158
 
219
159
 
220
160
  def get_printoptions():
221
- """Return the current print options.
222
-
223
- Returns
224
- -------
225
- dict
226
- Dictionary of current print options with keys
227
-
228
- - short : bool
229
- - xml : bool
230
- - codestream : bool
231
-
232
- For a full description of these options, see `set_printoptions`.
233
-
234
- See also
235
- --------
236
- set_printoptions
237
- """
238
161
  warnings.warn('Use get_option instead of get_printoptions.',
239
162
  DeprecationWarning)
240
163
  d = {}
glymur/tiff.py CHANGED
@@ -754,20 +754,6 @@ class Tiff2Jp2k(object):
754
754
  )
755
755
  self.logger.info(msg)
756
756
 
757
- if self.photo not in [
758
- libtiff.Photometric.MINISWHITE,
759
- libtiff.Photometric.MINISBLACK,
760
- libtiff.Photometric.PALETTE,
761
- libtiff.Photometric.YCBCR,
762
- libtiff.Photometric.RGB
763
- ]:
764
- photostr = self.tagvalue2str(libtiff.Photometric, self.photo)
765
- msg = (
766
- "Beware, the RGBA interface is attempting to read this TIFF "
767
- f"when it has a PhotometricInterpretation of {photostr}."
768
- )
769
- warnings.warn(msg)
770
-
771
757
  image = libtiff.readRGBAImageOriented(
772
758
  self.tiff_fp, self.imagewidth, self.imageheight
773
759
  )
glymur/version.py CHANGED
@@ -20,7 +20,7 @@ from .lib import tiff
20
20
 
21
21
  # Do not change the format of this next line! Doing so risks breaking
22
22
  # setup.py
23
- version = "0.13.1"
23
+ version = "0.13.2"
24
24
 
25
25
  version_tuple = parse(version).release
26
26
 
@@ -1,25 +0,0 @@
1
- glymur/__init__.py,sha256=k14IfdaYuTWXSpAIDR3LVDtXt9XKjr-ZSNXCyu8pQko,586
2
- glymur/_iccprofile.py,sha256=_WfQsT-BqEWQzQVTtuY7tSXqPjOtwvWGW36rKxlLv1s,4148
3
- glymur/codestream.py,sha256=R9eEFFwndNpx4ixFFisfUJXi9bX5Ofp-eqGfULXOq4w,59979
4
- glymur/command_line.py,sha256=jm-6dD2jcU_G7mJAJ0U5sanfG9kRy-j0-G3eSN_Ieek,7476
5
- glymur/config.py,sha256=BDjNKkjb7oOleqSTxYpvS4uhEIo0TknVjvelJSUJKGM,4443
6
- glymur/core.py,sha256=IDkk8FESyukQTB10LHBZ4VQM36NwKE4CXCcuJ407Kzg,3638
7
- glymur/jp2box.py,sha256=FyyWoVc0Pse5A1UQWiOPoOvMhxJKleKjrBXuXzIH6BI,112477
8
- glymur/jp2k.py,sha256=iEO5bd-Jzla5s2gflwXhPgrRNjUm0HyWPjhx2IK_mGI,54689
9
- glymur/jp2kr.py,sha256=glr57vIZEe2L_V8J5sOuYgnTGRTM4mGZeS240lxK9hw,31686
10
- glymur/options.py,sha256=-JZrrDzYsLZZ9Rce6l9e_lxtSGtXoWo9j3wajyDHVi8,6386
11
- glymur/tiff.py,sha256=bHqR0mQPcIAUjKEujaYLVpnSOP0gfGNCA20_ORaznq0,41653
12
- glymur/version.py,sha256=ovhSpUXA79dE_wg4pI2hs6BE68ZtSCno7sXhvJvWv0U,981
13
- glymur/data/__init__.py,sha256=pU_6hn1_8aAVVdgCAIUY1B73VkLf_nSlunQuPcGgVTU,1163
14
- glymur/data/goodstuff.j2k,sha256=xKQG68KMu33gYjRUDTQvam1Cue2tdio85rNp5J-rYZE,115220
15
- glymur/data/heliov.jpx,sha256=KXnYdBZgl25jcGLu-m-QfhuP9pqUXV0Hp9HHEdJqr34,1399071
16
- glymur/data/nemo.jp2,sha256=yJ1NkTEwU0B_gBtAiA1c5hxtGYSJtJgq6cHC2IHpj70,1132373
17
- glymur/lib/__init__.py,sha256=JnM9oPfcZhBDLKo7_yLS-lIRQ1wXb1N9hKKQ-G7vYVk,127
18
- glymur/lib/openjp2.py,sha256=qHvKDGtdCYuPtrFWnT248s90j8tju-kIx22vEDcAyfU,44941
19
- glymur/lib/tiff.py,sha256=hvRrpDh9wLGcAZ7GBHjHrRICk5PNJGEWn45ArRvGh20,50485
20
- Glymur-0.13.1.dist-info/LICENSE.txt,sha256=G9pvBgkJdPTtZqQmoRyIgAydtic1ZwWtOWBea9VMW7I,1077
21
- Glymur-0.13.1.dist-info/METADATA,sha256=GjT7wVmOncBZRNH7hj0J2YpVKIbrsJ1GzvsLmOR1UnU,1070
22
- Glymur-0.13.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
23
- Glymur-0.13.1.dist-info/entry_points.txt,sha256=inzxpDbDDfIxtdXpCncAHdAdwJfjtXt3xKvIOsuZsG8,93
24
- Glymur-0.13.1.dist-info/top_level.txt,sha256=D0SvtBUoPxOs40OTRW3l-kjGFHM6VrXS8yZPK5Fx2wY,7
25
- Glymur-0.13.1.dist-info/RECORD,,