How to change text of a psd file ?
I am trying to change the text of a particular layer of psd file but I am getting following error:
Traceback (most recent call last):
File "C:\Users\deepak.prasad\Desktop\python_scrapping\psd\app4.py", line 7, in <module>
layer_facts = doc.ArtLayers["appstoreName"]
File "C:\Users\deepak.prasad\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\win32com\client\dynamic.py", line 240, in __getitem__
return self._get_good_object_(self._oleobj_.Invoke(dispid, LCID, invkind, 1, index))
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe Photoshop', 'No such element', None, 0, -2147352565), None)
Below is my code:
import win32com.client
import os
psApp = win32com.client.Dispatch("Photoshop.Application")
psApp.Open(r"C:\\Users\\deepak.prasad\\Desktop\\python_scrapping\\psd\\Ad-format-final-1.psd")
doc = psApp.Application.ActiveDocument
layer_facts = doc.ArtLayers["appstoreName"]
text_of_layer = layer_facts.TextItem
text_of_layer.contents = "hello"
layer_facts.Kind = 1
text_of_layer.size = 16
