#!/usr/bin/python3
"""Encode → decode round-trip test using a small synthetic image."""

import numpy as np
from turbojpeg import TurboJPEG

jpeg = TurboJPEG()

# Create a synthetic test image (gradient)
height, width = 32, 32
bgr = np.zeros((height, width, 3), dtype=np.uint8)
bgr[..., 0] = np.linspace(0, 255, width, dtype=np.uint8)
bgr[..., 1] = np.linspace(255, 0, height, dtype=np.uint8)[:, None]

# Encode then decode
jpeg_bytes = jpeg.encode(bgr, quality=85)
decoded = jpeg.decode(jpeg_bytes)

assert decoded.shape == bgr.shape, decoded.shape
print("encode_decode OK:", decoded.shape)

