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=Image.open("new.tif")
im.save("new_tmp.tif") # or tempfile.mkstemp for a real temp file
del im
os.remove("new.tif")
os.rename("new_tmp.tif", "new.tif)

Michele
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to