[Gimp-user] Python script



Dear list members,

I wrote a script that adds an outline to the text. The script works as I expected with on exception. When it 
finished, it removes all textual information and converts the text into graphics. Could anyone give me an 
advice how to modify the script in order to keep the textual information unchanged? The script itself below.


#!/usr/bin/env python
# -*- coding: utf-8 -*-

from gimpfu import *

def outline_text(image, outline_color, outline_thikness):
    active = pdb.gimp_image_get_active_drawable(image)

    pdb.gimp_image_undo_group_start(image)
    
    if not pdb.gimp_drawable_is_text_layer(active):
        pdb.gimp_message('Cannot proceed on non textual layer')
        pdb.gimp_image_undo_group_end(image)
        return

    outline = pdb.gimp_vectors_new_from_text_layer(image, active)
    pdb.gimp_image_insert_vectors(image, outline , None, -1)

    saved_fg_color = pdb.gimp_context_get_foreground()
        
    pdb.gimp_context_set_foreground(outline_color)
    pdb.gimp_context_set_stroke_method(STROKE_LINE)
    pdb.gimp_context_set_line_width(float(outline_thikness))
    pdb.gimp_drawable_edit_stroke_item(active, outline)
        
    pdb.gimp_context_set_foreground(saved_fg_color)

    pdb.gimp_image_undo_group_end(image)

register(
        "python_fu_outline_text",
        "Adds an outline to a text",
        "Adds an outline to a text",
        "Alexander",
        "Alexander",
        "01.05.2018",
        "Text outline",
        "RGB* GRAY* INDEXED*",
        [
            (PF_IMAGE, "image", "Input image", None),
            (PF_COLOR, "outline_color", "Color", (255, 255, 255)),
            (PF_INT, "outline_thikness", ("Thickness"), "1"),
            ],
        [],
        outline_text, menu="<Image>/Illustration")
main()

With kind regards,
Alexander


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]