saving file permission denied on windows

Larry Bates larry.bates at websafe.com
Mon May 15 13:25:02 EDT 2006


zombek at gmail.com wrote:
> I'm making a small program which takes a folder with images and
> generates optimized normal-sized images and thumbnails using Python
> Imaging Lbrary (PIL). The problem is here:
> ....
> os.mkdir(self.output)
> ....
> img = Image.open(os.path.join(self.dir,file))
> img = img.resize(self.imgSize)
> # and here comes the error
> img.save(self.output, "JPEG", optimize=1)
> 
> IOError: [Errno 13] Permission Denied
> "D:\\Szymek\\python\\pythumb\\images\\proba"
> 
> I don't know what's going on, I didn't have any problems with it in the
> past. I tried to save it to a pre-made directory but the effect is the
> same, so I don't think it's connected with os.mkdir.
> 
I think you have a logic problem.

You can't save to a folder name, you must save to a file.  Note
that O/S is saying that permission is denied to the folder name
stored in self.output:

"D:\\Szymek\\python\\pythumb\\images\\proba"

You most likely meant:

img.save(os.path.join(self.output, file), "JPEG", optimize=1)

-Larry Bates



More information about the Python-list mailing list