Skip to content

clsid

Resolve Photoshop automation class IDs when no versioned ProgID is published.

A regular Photoshop installation publishes a versioned ProgID for every automation class (Photoshop.ActionDescriptor.190 and friends), which is what this library resolves classes through. Some installations -- notably portable or relocated copies -- register the very same classes under a bare CLSID with no ProgID at all. Those classes are perfectly creatable, but every Photoshop.<Class> lookup fails.

This module resolves a coclass name to its CLSID for those installations:

  1. Photoshop's own type library is read and indexed. The type library ships with Photoshop and declares every automation coclass by name, so this route is exact and instantiating anything is not required.
  2. If the type library is unavailable, the CLSIDs registered as Photoshop local servers are instantiated and asked for their coclass name through IDispatch::GetTypeInfo. This only depends on Photoshop itself and is used as a last resort, because it instantiates one automation object per candidate CLSID and costs roughly a second per candidate.

Both routes are read-only with respect to Photoshop's registration, and results are cached for the lifetime of the process.

reset_cache()

Forget every cached lookup. Only useful for tests and long lived processes.

Source code in photoshop/api/_clsid.py
88
89
90
91
92
93
94
95
def reset_cache() -> None:
    """Forget every cached lookup. Only useful for tests and long lived processes."""
    _CLASS_ID_CACHE.clear()
    _FAILURE_REASONS.clear()
    global _TYPE_LIBRARY_COCLASSES
    global _PROBED_COCLASSES
    _TYPE_LIBRARY_COCLASSES = None
    _PROBED_COCLASSES = None

resolution_failure_reason(object_name)

Return why a lookup of object_name returned None, for error reporting.

Parameters:

Name Type Description Default
object_name str

Photoshop coclass name that could not be resolved.

required

Returns:

Type Description
str

A human readable reason, or a fallback when no lookup recorded one.

Source code in photoshop/api/_clsid.py
76
77
78
79
80
81
82
83
84
85
def resolution_failure_reason(object_name: str) -> str:
    """Return why a lookup of ``object_name`` returned None, for error reporting.

    Args:
        object_name: Photoshop coclass name that could not be resolved.

    Returns:
        A human readable reason, or a fallback when no lookup recorded one.
    """
    return _FAILURE_REASONS.get(object_name, "no Photoshop automation class was inspected.")

resolve_photoshop_class_id(object_name)

Return the CLSID of a Photoshop coclass, or None when it cannot be resolved.

Parameters:

Name Type Description Default
object_name str

Photoshop coclass name, e.g. ActionDescriptor.

required

Returns:

Type Description
Optional[str]

The CLSID formatted as {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}, or None.

Source code in photoshop/api/_clsid.py
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
def resolve_photoshop_class_id(object_name: str) -> Optional[str]:
    """Return the CLSID of a Photoshop coclass, or None when it cannot be resolved.

    Args:
        object_name: Photoshop coclass name, e.g. ``ActionDescriptor``.

    Returns:
        The CLSID formatted as ``{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}``, or None.
    """
    with suppress(KeyError):
        return _CLASS_ID_CACHE[object_name]
    class_id = _lookup_class_id(object_name)
    # Only remember a miss once Photoshop has actually been seen. Otherwise a lookup that
    # ran before Photoshop was started would keep failing for the rest of the process.
    if class_id is not None or _saw_photoshop():
        _CLASS_ID_CACHE[object_name] = class_id
    return class_id

Last update: 2026-10-01
Created: 2026-10-01