[Image-SIG] problem with Image.open and Image.save

Michele Petrazzo - Unipex srl michele.petrazzo at unipex.it
Wed Oct 24 21:19:10 CEST 2007

Hohmann-Marriott, Martin (NIH/NIBIB) [V] wrote:
> Hi there,
> I try to open, (manipulate) and save an image, but run into problems
> on a "once in a while basis". My suspicion is that it has something
> to do with file access - so I made sure the image (new.tif) is not
> opened by any other program. Any suggestions for a work around.
> CODE: import Image
> im=Image.open("new.tif") im.save("new.tif")

This because you are trying to save on the same file! There is a problem
if no error are raised!

im.save("new_tmp.tif") # or tempfile.mkstemp for a real temp file
del im
os.rename("new_tmp.tif", "new.tif)


More information about the Image-SIG mailing list