From 7840074004536b44396083fcab75a9e6355e4a42 Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 18 Dec 2023 14:22:45 +0100 Subject: Initial commit --- src/infiray_irg.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/infiray_irg.py (limited to 'src/infiray_irg.py') diff --git a/src/infiray_irg.py b/src/infiray_irg.py new file mode 100644 index 0000000..9d573f6 --- /dev/null +++ b/src/infiray_irg.py @@ -0,0 +1,36 @@ +from PIL import Image +import numpy as np +import struct +import io + +def load(data): + def consume(n): + nonlocal data + out, data = data[:n], data[n:] + if len(out) < n: + raise ValueError('file is truncated') + return out + + header = consume(128) + if header[:2] != bytes([0xca, 0xac]) or header[-2:] != bytes([0xac, 0xca]): + raise ValueError('Header magic not found.') + + _unk0, coarse_section_length, y_res, x_res,\ + _zero0, _unk1, _zero1, fine_offset, _unk2, jpeg_length,\ + y_res_2, x_res_2, _unk3, = struct.unpack('