Skip to content

Commit

Permalink
fix is_processed method (removing the check on overviews, just printi…
Browse files Browse the repository at this point in the history
…ng a warning message)
  • Loading branch information
chpicone committed Apr 9, 2021
1 parent f102d92 commit 8970915
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions geotiflib/geotiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ def is_processed(self):
:return:
"""
info = self.info()
print(info)
if "Overviews:" not in info:
print("WARNING: the image does not contain overviews layers!")
return "COMPRESSION=YCbCr JPEG" in info \
and "Corner Coordinates:" in info \
and "Band 1 Block=512x512 Type=Byte, ColorInterp=Red" in info \
and "Band 2 Block=512x512 Type=Byte, ColorInterp=Green" in info \
and "Band 3 Block=512x512 Type=Byte, ColorInterp=Blue" in info \
and "Overviews:" in info
and "Band 3 Block=512x512 Type=Byte, ColorInterp=Blue" in info

def metadata(self, name):
"""
Expand Down
File renamed without changes.
Binary file added tests/data/AC04078710_no_overviews.tif
Binary file not shown.
10 changes: 8 additions & 2 deletions tests/test_geotiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ def test_is_processed():
assert tif.is_processed() is True


def test_is_processed_7mb():
path = os.path.join(get_data_folder(), "AC04078710_7mb.tif")
def test_is_processed_colorinterp_is_undefined():
path = os.path.join(get_data_folder(), "AC04078710_colorinterp_is_undefined.tif")
tif = geotiff.GeoTiff(path)
assert tif.is_processed() is False


def test_is_processed_no_overviews():
path = os.path.join(get_data_folder(), "AC04078710_no_overviews.tif")
tif = geotiff.GeoTiff(path)
assert tif.is_processed() is True
1 change: 1 addition & 0 deletions tests/test_tilejpegtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def test_process(mock_subproc_popen):
calls = [item["args"] for item in [item[2] for item in mock_subproc_popen.mock_calls] if len(item) > 1]
assert calls[0] == ['gdal_translate',
'-mo', 'NODATA_VALUES=0 0 0',
'-colorinterp', 'red,green,blue',
'-co', 'COMPRESS=JPEG',
'-co', 'PHOTOMETRIC=YCBCR',
'-co', 'TILED=YES',
Expand Down

0 comments on commit 8970915

Please sign in to comment.