From: Benjamin Kaplan on
On Mon, Feb 15, 2010 at 12:55 PM, fernando sedano <fersed(a)gmail.com> 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)
> ndvi.save("F:\Fire_scar_mapping\ILS3\ndvi_test","TIFF")
>
> ...........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?
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
----------
>>> print "F:\Fire_scar_mapping\ILS3\ndvi_test","TIFF"
F:\Fire_scar_mapping\ILS3
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")