How to call an external command in Gimp Plugin?

How to use an external command to make an edit of pic in the gimp and then return the result to the stage in a plugin or script.

Example in shell script.:

magick label.gif +matte
( +clone -shade 110x90 -normalize -negate +clone -compose Plus -composite )
( -clone 0 -shade 110x50 -normalize -channel BG -fx 0 +channel -matte )
-delete 0 +swap -compose Multiply -

The command above (imagemagick app) create a gif and i want put back in gimp stage. May be other simple option or application, but i need of return the edited back to gimp. Python, script fu? Thanks so much.

enter image description here

Upvotes: 1

Views: 382

Answers (2)

xenoid
xenoid

Reputation: 8904

There is a shellout.py Gimp plugin floating around from which you can borrow code. Typically:

  • you export the layer to a temp file (if you work on the whole image, you likely have to do a pdb.gimp_layer_new_from_visible())
  • call the executable with subprocess.Popen() and a list of arguments
  • load the result as a new layer with pdb.gimp_file_load_layer()

Upvotes: 1

fmw42
fmw42

Reputation: 53154

If GIMP will take stdin, then pipe from ImageMagick to GIMP using the GIMP XCF file format.

magick label.gif +matte 
( +clone -shade 110x90 -normalize -negate +clone -compose Plus -composite ) 
( -clone 0 -shade 110x50 -normalize -channel BG -fx 0 +channel -matte ) 
-delete 0 +swap -compose Multiply XCF:- | GIMP -

Upvotes: 0

Related Questions