[Python] Injecting Multi-Colored Text into an Existing PSD Text Layer?

Discussão em 'Python' iniciado por Stack, Maio 1, 2025.

  1. Stack

    Stack Membro Participativo

    I have a PSD that already contains a single text layer, and I want to inject a block of text into that layer where different words or phrases are each rendered in their own color (e.g. some words blue, others red, etc.).

    os.makedirs(os.path.dirname(png_path), exist_ok=True)

    app = win32com.client.Dispatch("Photoshop.Application.190")

    app.Open(psd_path)
    doc = app.Application.ActiveDocument

    artboard = doc.LayerSets.Item("redacao")

    tema_layer = artboard.ArtLayers.Item("Tema")
    texto_layer = artboard.ArtLayers.Item("Texto")

    tema_layer.TextItem.Contents = tema
    texto_layer.TextItem.Contents = text


    What’s the best approach with psd-tools (or related Python tooling) to insert text that already includes multiple color formats into an existing text layer, so that the layer preserves each segment’s individual color?

    Continue reading...

Compartilhe esta Página