Forum Wiki Galerie Kontakt Wie man Fragen richtig stellt. Tutorial Forum
Zurück   GIMP-Forum 3.0 > Arbeiten mit Gimp > GIMP-Ressourcen > Plug-ins

Hinweise
Alt 11.05.2019, 09:44   #27
Urmel_x
Benutzer
 
Registriert seit: 05.02.2019
Beiträge: 57
Standard

Zitat:
Zitat von Tscheppo Beitrag anzeigen
Bis heute hat mir niemand die Frage beantworten können, was der Unterschied zwischen dem "echten" und dem "Python-fu" Plugin ist!!!!!!!!!!!!

'echt' sind wohl beide - aber Python-Fu-Scripte rufen die benötigten Plugin-Prozeduren direkt auf:


Code:
from gimpfu import *


# main-procedure
def python_transform_by_points(timg, tdrawable, select_src, src_path, src_args, select_dst, dst_path, dst_args, one_path_mode, show_matrix ):
    # do something


register(
    "transform_by_points",
    "Transformation defined by mapping of 1..4 source-points to 1..4 other destination-points",
    "Transformation defined by mapping of 1..4 source-points to 1..4 other destination-points",
    "Andreas Zerbst",
    "(c) by Andreas Zerbst, Germany",
    "2019",
    "<Image>/Tools/Transform Tools/Transform by Points",
    "RGB*, GRAY*",
    [
        (PF_RADIO, "select_src", "Select the source for source-points: ", 0,
            (
                 ("choosen path", 0),
                 ( "numerical-input", 1),
                 ("current selection - not yet implemented", 2)
            )
        ),
        (PF_VECTORS, "src_path", "Name of source-points-path:", None),
        (PF_STRING, "src_arg", "Coordinates seperated by space: x0 y0 x1 y1 ...", ''),
        (PF_RADIO, "select_dst", "Select the source for destination-points: ", 0,
            (
                 ("choosen path", 0),
                 ( "numerical-input", 1),
                 ("aligned source-points", 2)
            )
        ),
        (PF_VECTORS, "dst_path", "Name of destination-points-path:", None),
        (PF_STRING, "dst_arg", "Coordinates seperated by space: x0 y0 x1 y1 ...", ''),
        (PF_OPTION, "one_path_mode", "Select basic transformation in one-path-mode:", 0,
            [
                " No select - use the default source-destination-points-mode ",
                " move      (need two points path) ",
                " flip      (need two points path) ",
                " scale     (need three points path) ",
                " rotate    (need three points path) ",
                " shear     (need four points path) "
            ]
        ),
        (PF_BOOL, "show_matrix", "show the transformation-matrix", False),
    ],
    [],
    python_transform_by_points
)

main()
Die 'bessere' Variante ist, die vorgefertigte Plugin-Klasse zuverwenden:


Code:
from gimpshelf import shelf
import gimp,gimpplugin



class Parameters:
    def __init__(self):
        if not hasattr(self, 'src_select_source'):
            self.src_select_source    = 2
        if not hasattr(self, 'src_coordinates'):
            self.src_coordinates    = ""
        # check all other attributes ...

def unshelf_parameters():
    if shelf.has_key(str_plugin_name):
        parameters = shelf[str_plugin_name]
        parameters.__init__()
        return parameters
    return Parameters()

def shelf_parameters(pp):
    shelf[str_plugin_name] = pp

params = [
    # (type, name, description
    ( PDB_INT32,    "run-mode",                "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }"),
    ( PDB_IMAGE,    "image",                "Input image"),
    ( PDB_DRAWABLE,    "drawable",             "Input drawable"),
    ( PDB_INT32,    "src_select_source",    "input-image: %s" % (label_select_source[LANGUAGE]) ),
    ( PDB_STRING,    "src_coordinates",        "input-image: %s" % (label_coordinates[LANGUAGE]) ),
    ( PDB_INT32,    "dst_select_source",    "output-image: %s" % (label_select_source[LANGUAGE]) ),
    ( PDB_STRING,    "dst_coordinates",        "output-image: %s" % (label_coordinates[LANGUAGE]) ),
    ( PDB_INT32,    "pre_blur",                label_pre_blur[LANGUAGE] ),
    ( PDB_INT32,    "interpolation",        label_interpolation[LANGUAGE] ),
    ( PDB_INT32,    "about_quadrangle",        label_about_quadrangle[LANGUAGE] ),
    ( PDB_INT32,    "about_mesh",            label_about_mesh[LANGUAGE] ),
    ( PDB_INT32,    "with_border",            label_with_border[LANGUAGE] ),
    ( PDB_INT32,    "anti_aliasing",        label_anti_aliasing[LANGUAGE] ),
    ( PDB_INT32,    "sharping",                label_sharping[LANGUAGE] ),
    ( PDB_FLOAT,    "epsilon",                label_epsilon[LANGUAGE] ),
    ( PDB_INT32,    "with_time",            label_with_time[LANGUAGE] ),
    ( PDB_INT32,    "show_help",            label_show_help[LANGUAGE] ),
]

class Transformation_by_Points(gimpplugin.plugin):

    def transform_by_points(self, run_mode, image, drawable,
        src_select_source        = 2,
        src_coordinates            = "",

        # set all other parameters ...
    ):
    
        if run_mode == RUN_NONINTERACTIVE:
            parameter = Parameters()
            parameter.src_select_source    = src_select_source
            parameter.src_coordinates    = src_coordinates
            # set all other attributes with pre-defined variables ...


            # use some class for the process

            transformator = Transformator( image, drawable )
            transformator.run( parameter )

        elif run_mode == RUN_INTERACTIVE:

            # create your own gui-window

            window = TransformationWindow( image, drawable )
            window.connect("destroy", gtk.main_quit)
            window.show()
            gtk.main()

        elif run_mode == RUN_WITH_LAST_VALS:
            parameter = unshelf_parameters()
            # use some class for the process

            transformator = Transformator( image, drawable )
            transformator.run( parameter )
        pluginEnde()

    def query(self):
        global LANGUAGE
        gimp.install_procedure(
            "transform_by_points",
            str_description_short[LANGUAGE],
            str_description_long[LANGUAGE],
            str_name_of_author,
            "(c) by %s, %s" % ( str_name_of_author, str_location_of_author ),
            str_year_of_programming,
            "<Image>%s%s" % ( str_menue_path, str_menue_entry ),
            str_image_types,
            PLUGIN,
            params,
            []
        )

    def start(self):
        gimpplugin.plugin.start(self)
       
if __name__ == '__main__':
    Transformation_by_Points().start()
Urmel_x ist offline   Mit Zitat antworten
 

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist An.
Smileys sind An.
[IMG] Code ist An.
HTML-Code ist Aus.

Gehe zu

Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
[Plugin] PHotoshop Plugins in GIMP Arathis GIMP-Ressourcen 24 21.01.2010 21:38
PlugIns für Newbies micha0816 GIMP-Ressourcen 4 25.09.2005 14:10


Alle Zeitangaben in WEZ +2. Es ist jetzt 00:35 Uhr.


Powered by vBulletin® Version 3.8.2 (Deutsch)
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.