rasterio/tests/test_png.py
Sean Gillies 414a75686e Write/update PNG and JPEG.
Indirectly, using MEM datasets as an intermediary.

Closes #177.

Also add --driver option to rio-stack for integration testing.

Move CLI main to main.py
2014-10-09 12:48:49 -06:00

21 lines
630 B
Python

import logging
import subprocess
import sys
import re
import numpy
import rasterio
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
def test_write_ubyte(tmpdir):
name = str(tmpdir.mkdir("sub").join("test_write_ubyte.png"))
a = numpy.ones((100, 100), dtype=rasterio.ubyte) * 127
with rasterio.open(
name, 'w',
driver='PNG', width=100, height=100, count=1,
dtype=a.dtype) as s:
s.write_band(1, a)
info = subprocess.check_output(["gdalinfo", "-stats", name]).decode('utf-8')
assert "Minimum=127.000, Maximum=127.000, Mean=127.000, StdDev=0.000" in info