Add WebP quality control and selective visualization (--only / --skip)

- WebP output now uses quality=85 by default (down from lossless),
  reducing file size by ~75% (35MB → 5-8MB per visualization)
- Added --quality N (1-100) and --lossless flags in CLI and run.sh
- Added --only and --skip to select/exclude specific visualizations
  (e.g., --only hillshade,svf,lrm or --skip ortho,topo)
- VIZ_STEPS filtering is done in LidarArchaeoPipeline.__init__
- SharedDEM is skipped when all selected visualizations already exist
- Invalid visualization names are validated at startup with clear error

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Jacquin Antoine
2026-05-14 21:15:21 +02:00
parent 6ed4972afc
commit 34b79ac2c2
4 changed files with 103 additions and 15 deletions

View File

@ -271,7 +271,7 @@ def _nice_scale(extent_m):
return chosen, f"{chosen} m"
def tif_to_png(tif_file, vis_dir, resolution, keep_tif=False, source_info=None):
def tif_to_png(tif_file, vis_dir, resolution, keep_tif=False, source_info=None, quality=85):
"""Convert GeoTIFF to visualization WebP with GPS coordinates, legend, and scale bar.
Args:
@ -279,6 +279,8 @@ def tif_to_png(tif_file, vis_dir, resolution, keep_tif=False, source_info=None):
vis_dir: Output directory for the WebP file.
resolution: Grid resolution in m/px.
keep_tif: If True, keep the source TIFF after conversion.
source_info: Dict with method/date/basename for metadata.
quality: WebP quality (1-100). Use 100 for lossless. Default 85.
Returns:
Path to output WebP file, or None on failure.
@ -589,7 +591,10 @@ def tif_to_png(tif_file, vis_dir, resolution, keep_tif=False, source_info=None):
plt.close()
img = PILImage.open(str(png_temp))
img.save(str(webp_file), format='WEBP', lossless=True)
if quality >= 100:
img.save(str(webp_file), format='WEBP', lossless=True)
else:
img.save(str(webp_file), format='WEBP', quality=quality)
png_temp.unlink(missing_ok=True)
# Delete source TIFF (unless --keep-tif)