basic processing done

This commit is contained in:
2026-01-06 19:34:25 +01:00
parent 275d53d1dc
commit a1f3c0638d
5 changed files with 15 additions and 7 deletions

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

View File

Binary file not shown.

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

View File

@@ -2,5 +2,5 @@ from modules.raw_parser import (parse_raw_image)
if __name__ == "__main__":
parse_raw_image("./assets/foo.CR2", 2000)
parse_raw_image("./src/assets/foo.CR2", 1900, "png")

View File

@@ -1,9 +1,17 @@
from PIL import Image
import math
def parse_raw_image(src,target_width, target_height):
def parse_raw_image(src: str, max_size_px: int, target_extension: str):
rawImage = Image.open(src)
# Use the PIL raw decoder to read the data.
# the 'F;16' informs the raw decoder that we are reading
# a little endian, unsigned integer 16 bit data.
# img = Image.fromstring('L', imgSize, rawData, 'raw', 'F;16')
rawImage.save("foo.png")
if (rawImage.height > rawImage.width):
target_height = max_size_px
target_width = math.ceil(rawImage.width * max_size_px / rawImage.height)
else:
target_width = max_size_px
target_height = math.ceil(rawImage.height * max_size_px / rawImage.width)
rawImage = rawImage.resize((target_width, target_height))
last_dot = src.rfind(".")
result_path = src[:last_dot]
rawImage.save(result_path + "." + target_extension)