Debian Codegraph @

debian/tests/crop

raw symbols SCIP
1 #!/usr/bin/python3
2 """Lossless crop test."""
3
4 import numpy as np
5 from turbojpeg import TurboJPEG
6
7 jpeg = TurboJPEG()
8 img = np.random.randint(0, 255, (64, 64, 3), dtype=np.uint8)
9 jpeg_bytes = jpeg.encode(img)
10
11 cropped_bytes = jpeg.crop(jpeg_bytes, 8, 8, 32, 32)
12 cropped = jpeg.decode(cropped_bytes)
13
14 assert cropped.shape[0] > 0 and cropped.shape[1] > 0
15 print("cropped shape:", cropped.shape)
16