thx for your answer you right, i'm on Windows i'm agree with you, my code is ugly with file path, it's just a crash code simplification for my post
the problem is with os.remove on original image if i launch my script in interactive mode, without the last two lines ( os.remove and os.rename) python -i compress_dwaa.py so my python interprete still alive i can't delete by hand my file because : "file is open by python.exe process" 2018-04-11 17:01 GMT+02:00 Scott Wilson <sc...@propersquid.com>: > Not sure if this will help you out, but out of curiosity, have you tried > only deleting or renaming the file? From what I remember when I used oiio > on Windows, I was able to do delete/rename. > > Also, here's some general Python tips: > - Use os.splitext(path) to get everything leading up to the extension, and > the .ext. For example "my file.ext" becomes ("my file", ".ext") > - Use os.path.join(pathroot, filename) when joining paths, because it > handled when the path root ends with a '/' or not. > - Strong formatting is generally preferred to strong concatenation because > it is usually faster, and can be more readable. For example: outfile = > "{}.tmp{}".format(filename, ext) > > On Wed, Apr 11, 2018, 7:39 AM Stéphane Bertrand, <stef.ker...@gmail.com> > wrote: > >> hi all, >> >> i've this simple script, inpire by snippet in the docs : >> >> import os >> import OpenImageIO as oiio >> >> >> DIR_PATH = r"D:\Seq02\Scn01\Shot01\Left\pass\Decor\\" >> IN_FILE = "Seq02_Scn01_Shot01_Decor_0000.exr" >> >> >> ext = IN_FILE.rfind(".") >> out_file = IN_FILE[:ext]+ ".tmp" + IN_FILE[ext:] >> >> >> def write_image (image, filename, format=oiio.UNKNOWN) : >> if not image.has_error : >> image.set_write_format (format) >> image.write (filename) >> if image.has_error : >> print("Error writing", filename, ":", image.geterror()) >> >> img = oiio.ImageBuf(DIR_PATH+IN_FILE) >> img.specmod().attribute("compression", "dwaa") >> write_image(img, DIR_PATH+out_file) >> >> os.remove(DIR_PATH+IN_FILE) >> os.rename(DIR_PATH+out_file, DIR_PATH+IN_FILE) >> >> it's a simple script for inplace convert with dwa compression a EXR file >> but i've a PermissionError, my own process have hands on my file >> i'll try to add >> img.reset(oiio.ImageSpec()) >> for free my image >> but not >> >> thx for your help >> Stéphane >> >> >> _______________________________________________ >> Oiio-dev mailing list >> Oiio-dev@lists.openimageio.org >> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org >> > > _______________________________________________ > Oiio-dev mailing list > Oiio-dev@lists.openimageio.org > http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org > >
_______________________________________________ Oiio-dev mailing list Oiio-dev@lists.openimageio.org http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org