Skip to content

Commit

Permalink
DAS-2276: Simplify prepare_raster_for_writing.
Browse files Browse the repository at this point in the history
  • Loading branch information
flamingbear committed Dec 13, 2024
1 parent 664e439 commit 32fb4db
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions hybig/browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit 32fb4db

Please sign in to comment.