saving a TIFF

Benjamin Kaplan benjamin.kaplan at
Mon Feb 15 19:06:51 CET 2010

On Mon, Feb 15, 2010 at 12:55 PM, fernando sedano <fersed at> wrote:
> I'm trying to save an image created from two arrays (I'm using numpy and
> PIL):
> n=(b4a-b3a)/(b4a+b3a);
> ndvi = Image.fromarray(n)
> ...........but I get the following error message:
> IOError: [Errno 22] invalid mode ('wb') or filename:
> 'F:\\Fire_scar_mapping\\ILS3\ndt'
> Could anybody tell me what I'm doing wrong?
> --
>>> print "F:\Fire_scar_mapping\ILS3\ndvi_test","TIFF"
dvi_test TIFF
Notice anything wrong with that? Unlike the Windows command line,
Python neither knows nor cares that the string you're entering is a
file name. It sees the \n and converts it to a newline. Either double
up your backslashes ( "F:\\Fire_scar_mapping\\ILS3\\ndvi_test"), use a
raw string (r"F:\Fire_scar_mapping\ILS3\ndvi_test") or use forward
slashes ("F:/Fire_scar_mapping/ILS3/ndvi_test")

More information about the Python-list mailing list