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

"deleteAndFillSelection" #363

Open
MichaelB82 opened this issue Oct 16, 2024 · 0 comments
Open

"deleteAndFillSelection" #363

MichaelB82 opened this issue Oct 16, 2024 · 0 comments

Comments

@MichaelB82
Copy link

I want to write same function for "deleteAndFillSelection" -- can anybody help me ?

def content_aware_fill(ps, doc, left, top, right, bottom, hull_points):
# Deselect any current selections
doc.selection.deselect()

# Define the selection area
if hull_points is not None:
    doc.selection.select(hull_points)
else:
    left, top, right, bottom = int(left), int(top), int(right), int(bottom)
    selection_points = ((left, top), (right, top), (right, bottom), (left, bottom))
    doc.selection.select(selection_points)

# Perform Content-Aware Fill
desc12 = ps.ActionDescriptor()

# Fill method using content-aware
idFl = ps.app.charIDToTypeID("Fl  ")
idUsng = ps.app.charIDToTypeID("Usng")
idFlCn = ps.app.charIDToTypeID("FlCn")
idcontentAware = ps.app.stringIDToTypeID("contentAware")
desc12.putEnumerated(idUsng, idFlCn, idcontentAware)

# Set opacity to 100%
idOpct = ps.app.charIDToTypeID("Opct")
idPrc = ps.app.charIDToTypeID("#Prc")
desc12.putUnitDouble(idOpct, idPrc, 100.0)

# Set blending mode to Normal
idMd = ps.app.charIDToTypeID("Md  ")
idBlnM = ps.app.charIDToTypeID("BlnM")
idNrml = ps.app.charIDToTypeID("Nrml")
desc12.putEnumerated(idMd, idBlnM, idNrml)

# Execute the action
ps.app.executeAction(idFl, desc12, ps.DialogModes.DisplayNoDialogs)

# Deselect after filling
doc.selection.deselect()
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