saving file permission denied on windows

Z

zombek

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.
 
D

defcon8

Have you checked the persmissions to the folder? You can look from the
properties of the folder to see.
 
Z

zombek

The permission is OK I guess... I don't see anything about permission
there, but I tried to save to maaaaaany other catalogs even to C:\ and
D:\ and it raised the same error
 
L

Larry Bates

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top