Merge pull request #42 from riaanvddool/gdal_plugin

Add GDAL image loader.
This commit is contained in:
Stefan van der Walt
2011-10-10 04:19:28 -07:00
2 changed files with 23 additions and 0 deletions
@@ -0,0 +1,4 @@
[gdal]
description = Image reading via the GDAL Library (www.gdal.org)
provides = imread
+19
View File
@@ -0,0 +1,19 @@
__all__ = ['imread']
import numpy as np
try:
import osgeo.gdal as gdal
except ImportError:
raise ImportError("The GDAL Library could not be found. "
"Please refer to http://www.gdal.org/ "
"for further instructions.")
def imread(fname, dtype=None):
"""Load an image from file.
"""
ds = gdal.Open(fname)
return ds.ReadAsArray().astype(dtype)