Skip to content

Commit

Permalink
Only support 0 < sbit <= 16 in upload_image
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-austin committed Feb 10, 2025
1 parent 5b700bb commit 9d7c470
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions operationsgateway_api/src/records/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ def upload_image(input_image: Image) -> Optional[str]:
image_bytes = BytesIO()
try:
image = PILImage.fromarray(input_image.image.data)
if input_image.image.bit_depth is not None:
bit_depth = input_image.image.bit_depth
if bit_depth is not None and 0 < bit_depth <= 16:
info = PngImagePlugin.PngInfo()
sbit = input_image.image.bit_depth.to_bytes(1, byteorder="big")
sbit = bit_depth.to_bytes(1, byteorder="big")
info.add(b"sBIT", sbit)
image.save(image_bytes, format="PNG", pnginfo=info)
else:
Expand Down

0 comments on commit 9d7c470

Please sign in to comment.