Skip to content

Commit

Permalink
feat: add gray_webp preset TDE-482 (#149)
Browse files Browse the repository at this point in the history
* feat/add-gray-webp-preset

* fix: formatting

* fix: add GTIFF_SRS_SOURCE=EPSG environment variable

* fix: temp fix to remove bands checks

* fix: formatting
  • Loading branch information
amfage authored Sep 21, 2022
1 parent c674366 commit 396dc16
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ RUN poetry config virtualenvs.create false \
COPY ./scripts/ /app/scripts/

ENV PYTHONPATH="/app"
ENV GTIFF_SRS_SOURCE="EPSG"

WORKDIR /app/scripts
38 changes: 38 additions & 0 deletions scripts/gdal/gdal_preset.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@

GDAL_PRESET_WEBP = [
"gdal_translate",
"-q",
"-a_srs",
"EPSG:2193",
"-of",
Expand All @@ -68,11 +69,48 @@
"sparse_ok=true",
]

GDAL_PRESET_GRAY_WEBP = [
"gdal_translate",
"-q",
"-a_srs",
"EPSG:2193",
"-b",
"1",
"-b",
"1",
"-b",
"1",
"-a_nodata",
"255",
"-of",
"COG",
"-co",
"compress=webp",
"-co",
"num_threads=all_cpus",
"-co",
"quality=100",
"-co",
"overview_compress=webp",
"-co",
"bigtiff=yes",
"-co",
"overview_resampling=lanczos",
"-co",
"blocksize=512",
"-co",
"overview_quality=90",
"-co",
"sparse_ok=true",
]


def get_gdal_command(preset: str) -> List[str]:
get_log().info("gdal_preset", preset=preset)
if preset == "lzw":
return GDAL_PRESET_LZW
if preset == "webp":
return GDAL_PRESET_WEBP
if preset == "gray_webp":
return GDAL_PRESET_GRAY_WEBP
raise Exception(f"Unknown GDAL preset: {preset}")
4 changes: 2 additions & 2 deletions scripts/non_visual_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ def run(self) -> None:

if gdalinfo_success:
self.check_no_data(gdalinfo_result)
self.check_band_count(gdalinfo_result)
self.check_color_interpretation(gdalinfo_result)
# self.check_band_count(gdalinfo_result)
# self.check_color_interpretation(gdalinfo_result)
gdalsrsinfo_tif_command = ["gdalsrsinfo", "-o", "wkt"]
try:
gdalsrsinfo_tif_result = run_gdal(gdalsrsinfo_tif_command, self.path)
Expand Down

0 comments on commit 396dc16

Please sign in to comment.