// Run in a fresh writable directory: native image saving refuses an existing path.
import aner.image
import aner.tensor

let work = image.context(workers: 1, memory_mb: 32)
let samples: Tensor = [[0.0, 1024.0, 60000.0], [7.0, 500.0, 65535.0]]
let source = image.from_tensor(work, samples, dtype: "UInt16")
source.save("image-roundtrip.pgm")
let info = image.inspect(work, "image-roundtrip.pgm")
print(info.width())
print(info.height())
print(info.dtype())
print(info.pages())
let restored = image.load(work, "image-roundtrip.pgm")
print(restored.sample(2, 1))
let region = image.load_region(work, "image-roundtrip.pgm", x: 1, y: 0, width: 2, height: 2)
print(region.sample(0, 0))
print(image.available("png"))
print(image.capabilities())
