from PIL import Image
import math

def parse_raw_image(src: str, max_size_px: int, target_extension: str):
	rawImage = Image.open(src)

	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)
