From 32fb4db9ca4dc6e0322a464d23754b5884282093 Mon Sep 17 00:00:00 2001 From: Matt Savoie Date: Fri, 13 Dec 2024 11:55:10 -0700 Subject: [PATCH] DAS-2276: Simplify prepare_raster_for_writing. --- hybig/browse.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/hybig/browse.py b/hybig/browse.py index 1fb1266..d760cbf 100644 --- a/hybig/browse.py +++ b/hybig/browse.py @@ -363,16 +363,14 @@ def prepare_raster_for_writing( input_bands: int, ) -> tuple[ndarray, dict | None]: """Remove alpha layer if writing a jpeg.""" - color_map = None if driver == 'JPEG' and raster.shape[0] == 4: - raster = raster[0:3, :, :] - return raster, color_map + return raster[0:3, :, :], None - if input_bands == 1 and driver == 'PNG': + if driver == 'PNG' and input_bands == 1: # we only paletize single band input data - raster, color_map = palettize_raster(raster) + return palettize_raster(raster) - return raster, color_map + return raster, None def palettize_raster(raster: ndarray) -> tuple[ndarray, dict]: