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

General Photoshop error occurred. This functionality may not be available in this version of Photoshop. The command "Play" is not currently available #23

Open
sowmyakavali opened this issue Jun 7, 2023 · 1 comment

Comments

@sowmyakavali
Copy link

sowmyakavali commented Jun 7, 2023

I have person image with white background , and I have one more image which I am going to use it as new background for person. I am trying to do it in photoshop application with python script.

This is the script I have tried,

import os
import win32com.client

SILENT_CLOSE = 2

# This actually fires up Photoshop if not already running.
ps = win32com.client.Dispatch("Photoshop.Application")
ps.DisplayDialogs = 3            # psDisplayNoDialogs
ps.Preferences.RulerUnits = 1    # psPixels
folder_path = r"C:\Users\MCPL-265\Desktop\ps_connect\TEST\Input"

# Get a list of files in the folder
files = os.listdir(folder_path)
output_folder = r"C:\Users\MCPL-265\Desktop\ps_connect\TEST\Output"

# Create the output folder if it doesn't exist
if not os.path.exists(output_folder):
    os.makedirs(output_folder)

# Loop through the files and open them in Photoshop
for file in files:
    file_path = os.path.join(folder_path, file)
    ps.Open(file_path)

    ps.DoAction("Set1", "Actions")
    output_file = os.path.join(output_folder, file)

    jpgSaveOptions = win32com.client.Dispatch("Photoshop.JPEGSaveOptions" )
    ps.ActiveDocument.SaveAs(output_file, jpgSaveOptions, True, 2)

ps.Quit() # Stops the Photoshop application

NOTE : Here Set1 is the custom action that I have added already in photoshop application.
This is the custom action I have loaded.

But It is throwing this error

File "<COMObject Photoshop.Application>", line 2, in DoAction
pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe Photoshop', 'General Photoshop error occurred. This functionality may not be available in this version of Photoshop.\n- The command "Play" is not currently available.', None, 0, -2147212704), None)

Please can anyone help me to resolve this issue?

@oh-ok
Copy link
Contributor

oh-ok commented Jul 9, 2023

Looks like you're referencing the Action Set, not the Action itself here. Changing ps.DoAction("Set1", "Actions") to ps.DoAction("BG", "Set1") will probably make this work.

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

2 participants