I am having trouble overwriting an existing file using Python, comTypes and Photoshop.
The error message I am receiving is not very helpful.
Here is a little bit of code to illustrate
psApp.DisplayDialogs = 3 # display no dialogs
tgaOptions = comtypes.client.CreateObject('Photoshop.TargaSaveOptions')
tgaOptions.RLECompression = False
tgaOptions.Resolution = 32
tgaOptions.AlphaChannels = False
filepath = 'c:/temp/myTargaFile.tga'
doc.SaveAs(filepath, tgaOptions, True, 2) # filename, save options, save as copy, lowercase extension
The error message
_ctypes.COMError: (-2147212704, None, (None, None, None, 0, None))
So I think the problem is related to the fact that I am not opening the texture that is on disk. I am generating a new photoshop document from a layered PSD and then saving the new doc over the existing file.
existing layered PSD —> new photoshop document —> overwrite existing file on disk.
I tested this process manually by performing all the steps myself and didn’t have any problems saving over an existing file with a new photoshop document, but I can’t get it to work with scripting.