photoshop-python-api: Crashes on Photoshop 2023

Describe the bug When I upgrade photoshop to the latest version I got an exception, I want to use 2023 because of better subject selection tools (which we use)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python\Python310\lib\concurrent\futures\process.py", line 246, in _process_worker
    r = call_item.fn(*call_item.args, **call_item.kwargs)
  File "C:\photoshop\src\main_child.py", line 130, in edit_image
    with Session(action="open", file_path=load_dest, auto_close=True) as s:
  File "C:\Python\Python310\lib\site-packages\photoshop\session.py", line 339, in __enter__
    self.run_action()
  File "C:\Python\Python310\lib\site-packages\photoshop\session.py", line 329, in run_action
    _action()
  File "C:\Python\Python310\lib\site-packages\photoshop\session.py", line 318, in _action_open
    self.active_document = self.app.open(self.path)
  File "C:\Python\Python310\lib\site-packages\photoshop\api\application.py", line 385, in open
    document = self.app.open(document_file_path, document_type, as_smart_object)
  File "C:\Python\Python310\lib\site-packages\comtypes\client\dynamic.py", line 121, in __getattr__
    result = self._comobj.Invoke(dispid, _invkind=flags)
  File "C:\Python\Python310\lib\site-packages\comtypes\automation.py", line 799, in Invoke
    raise COMError(hresult, text, details)
_ctypes.COMError: (-2147352567, 'Er is een uitzondering opgetreden.', ('Ongeldig argument - argument 1\n- Vereiste waarde ontbreekt', 'Adobe Photoshop', None, 0, -2147220262))
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\photoshop\src\main_child.py", line 51, in start_editing_images
    edit_outfits(INPUT_PATH_OUTFIT, OUTPUT_PATH_OUTFIT)
  File "C:\photoshop\src\main_child.py", line 91, in edit_outfits
    edit_images(original_directory, directory_path, "automatic-action")
  File "C:\photoshop\src\main_child.py", line 117, in edit_images
    timeout(TIMEOUT_PER_IMAGE_IN_SECONDS, edit_image, input_path, output_path, action_name, file)
  File "C:\photoshop\src\main_child.py", line 238, in timeout
    return submit_response.result(timeout=t)
  File "C:\Python\Python310\lib\concurrent\futures\_base.py", line 446, in result
    return self.__get_result()
  File "C:\Python\Python310\lib\concurrent\futures\_base.py", line 391, in __get_result
    raise self._exception
_ctypes.COMError: (-2147352567, 'Er is een uitzondering opgetreden.', ('Ongeldig argument - argument 1\n- Vereiste waarde ontbreekt', 'Adobe Photoshop', None, 0, -2147220262))

To Reproduce


def edit_image(input_path: str, output_path: str, action_name: str, file: str):
    load_dest = os.path.join(input_path, file)
    out_dest = os.path.join(output_path, file)

    with Session(action="open", file_path=load_dest, auto_close=True) as s:
        # execute action for nicer and brighter colors
        if do_filter():
            s.app.doAction(action_name, action_name)

        # save results
        doc = s.active_document
        options = ps.JPEGSaveOptions(quality=12)
        doc.saveAs(out_dest, options, True)

Expected behavior Not to crash

Desktop (please complete the following information):

  • OS: Windows 10 Pro
  • Photoshop Version: Photoshop-2023
  • Python Version: Python 3.10.5

Additional context It worked in Photoshop 2022

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 18 (5 by maintainers)

Most upvoted comments

Hi @RichardLindhout , I have deployed a new version to support Photoshop-2023,please try upgrade use the latest version.

Cheers!

@loonghao do you have/run photoshop 2023?

Yes. my photoshop version is 24.0.0 20221013.r.59 3a3d761 x64 and os version is win 11

I believe the example code in the repo also does not work in 2023