Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot apply content aware filter to selected area. #12

Open
samp50old opened this issue Aug 24, 2020 · 0 comments
Open

Cannot apply content aware filter to selected area. #12

samp50old opened this issue Aug 24, 2020 · 0 comments

Comments

@samp50old
Copy link

samp50old commented Aug 24, 2020

Hello, I am trying to apply a content aware fill to a selected area in my currently opened Photoshop doc. However, when I try to run .putEnumerated with "contentAware" as an option, Python throws the following error:

    desc12.putEnumerated( idUsng, idFlCn, idcontentAware )
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\win32com\client\dynamic.py", 
line 516, in __getattr__
    ret = self._oleobj_.Invoke(retEntry.dispid,0,invoke_type,1)
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe Photoshop', 'Illegal argument - argument 1\n- 
Required value is missing', None, 0, -2147220262), None) 

I am running this code with Python 3.7.6 on Windows Server 2019. I have successfully ran all the example code in this repo, but, again, the "contentAware" keyword seems to throw everything off. It is not clear what the "required value" is, per the error message, I have written the StringIDToTypeID and CharIDToTypeID the same as in the example code.
Full code is below:

# Get the active document and make a new selection.
import sys
from comtypes.client import GetActiveObject, CreateObject
from win32com.client import Dispatch

xPoint = int(sys.argv[2])
yPoint = int(sys.argv[3])
xWidth = int(sys.argv[4])
yWidth = int(sys.argv[5])
xSw = xPoint + xWidth
ySh = yPoint + yWidth
dialogMode = 3

# Make sure PS is OPEN here...

app = GetActiveObject("Photoshop.Application")
docRef = app.open(sys.argv[1])
# Make selection on document according to args
activeObj = app.ActiveDocument
sel_area = ((xPoint, yPoint), (xSw, yPoint), (xSw, ySh), (xPoint, ySh))
docRef.Selection.Select(sel_area, 1, 5.5, False) # Get rid of last three args 
idFl = app.CharIDToTypeID( "Fl  " )
desc12 = Dispatch('Photoshop.ActionDescriptor')
idUsng = app.CharIDToTypeID( "Usng" )
idFlCn = app.CharIDToTypeID( "FlCn" )
idcontentAware = app.StringIDToTypeID("contentAware")
desc12.putEnumerated( idUsng, idFlCn, idcontentAware )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant