diff --git a/.snyk b/.snyk new file mode 100644 index 0000000..989152f --- /dev/null +++ b/.snyk @@ -0,0 +1,4 @@ +# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. +version: v1.25.0 +language-settings: + python: "3.7" diff --git a/CHANGELOG.md b/CHANGELOG.md index ec2bfdd..6941fe6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ HyBIG follows semantic versioning. All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). +## [unreleased] - 2024-06-06 + +### Changed +Updated internal library dependencies. ## [v1.2.0] - 2024-05-28 diff --git a/README.md b/README.md index 97da4fa..1255e5d 100644 --- a/README.md +++ b/README.md @@ -197,7 +197,7 @@ environment via conda, and then install the necessary dependencies for the service within that environment via conda and pip then install the pre-commit hooks. ``` -> conda create -name hybig-env python==3.11 +> conda create --name hybig-env python==3.11 > conda install --file conda_requirements.txt > pip install -r pip_requirements.txt > pip install -r dev-requirements.txt diff --git a/conda_requirements.txt b/conda_requirements.txt index 9263876..fc2f8ef 100644 --- a/conda_requirements.txt +++ b/conda_requirements.txt @@ -1 +1 @@ -gdal==3.6.3 +gdal==3.9 diff --git a/harmony_browse_image_generator/browse.py b/harmony_browse_image_generator/browse.py index 39dedcd..a867a60 100644 --- a/harmony_browse_image_generator/browse.py +++ b/harmony_browse_image_generator/browse.py @@ -29,6 +29,7 @@ TRANSPARENT, TRANSPARENT_IDX, TRANSPARENT_RGBA, + all_black_color_map, get_color_palette, remove_alpha, ) @@ -286,9 +287,9 @@ def get_color_map_from_image(image: Image) -> dict: """ color_tuples = np.array(image.getpalette(rawmode='RGBA')).reshape(-1, 4) - color_map = {} - for idx in range(0, color_tuples.shape[0]): - color_map[idx] = tuple(color_tuples[idx]) + color_map = all_black_color_map() + for idx, color_tuple in enumerate(color_tuples): + color_map[idx] = tuple(color_tuple) return color_map diff --git a/harmony_browse_image_generator/color_utility.py b/harmony_browse_image_generator/color_utility.py index 750a836..ce62d07 100644 --- a/harmony_browse_image_generator/color_utility.py +++ b/harmony_browse_image_generator/color_utility.py @@ -125,6 +125,11 @@ def get_remote_palette_from_source(source: HarmonySource) -> dict: raise HyBIGNoColorInformation('No color in source') from exc +def all_black_color_map(): + """Return a full length rgba color map with all black values.""" + return {idx: (0, 0, 0, 255) for idx in range(256)} + + def convert_colormap_to_palette(colormap: dict) -> ColorPalette: """Convert a GeoTIFF palette to GDAL ColorPalette. diff --git a/pip_requirements.txt b/pip_requirements.txt index 0353a86..cbaf9cd 100644 --- a/pip_requirements.txt +++ b/pip_requirements.txt @@ -1,8 +1,8 @@ -harmony-service-lib~=1.0.26 +harmony-service-lib~=1.0.27 pystac~=0.5.6 -matplotlib==3.7.1 -rasterio==1.3.6 -rioxarray==0.15.0 -numpy==1.24.2 -pillow==10.0.0 -pyproj==3.6.0 +matplotlib==3.9.0 +rasterio==1.3.10 +rioxarray==0.15.5 +numpy==1.26.4 +pillow==10.3.0 +pyproj==3.6.1 diff --git a/tests/unit/test_browse.py b/tests/unit/test_browse.py index 52ad50f..9ea1293 100644 --- a/tests/unit/test_browse.py +++ b/tests/unit/test_browse.py @@ -631,11 +631,14 @@ def test_get_color_map_from_image(self): test_image.putpalette(palette_sequence, rawmode='RGBA') expected_color_map = { - 0: (255, 0, 0, 255), - 1: (0, 255, 0, 255), - 2: (0, 0, 255, 255), - 3: (225, 100, 25, 25), - 4: (0, 0, 0, 0), + **{ + 0: (255, 0, 0, 255), + 1: (0, 255, 0, 255), + 2: (0, 0, 255, 255), + 3: (225, 100, 25, 25), + 4: (0, 0, 0, 0), + }, + **{idx: (0, 0, 0, 255) for idx in range(5, 256)}, } actual_color_map = get_color_map_from_image(test_image)