#!/usr/bin/python3 """Lossless crop test.""" import numpy as np from turbojpeg import TurboJPEG jpeg = TurboJPEG() img = np.random.randint(0, 255, (64, 64, 3), dtype=np.uint8) jpeg_bytes = jpeg.encode(img) cropped_bytes = jpeg.crop(jpeg_bytes, 8, 8, 32, 32) cropped = jpeg.decode(cropped_bytes) assert cropped.shape[0] > 0 and cropped.shape[1] > 0 print("cropped shape:", cropped.shape)