It is currently Mon Jul 27, 2026 12:40 pm


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: shellout
PostPosted: Tue Jul 12, 2011 3:57 pm  (#1) 
Offline
GimpChat Member
User avatar

Joined: Jun 04, 2011
Posts: 254
Can someone teach me how to put new programs in shellout ? i don't know how.

thanks in advance

opps just noticed i put this in the wrong spot sorry

_________________
Image


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: shellout
PostPosted: Tue Jul 12, 2011 4:50 pm  (#2) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
you don't put programs in ShellOut...not exactly
You install the program(s) as usual...next you put the PATH(s) for the program(s) to call from gimp in ShellOut

PS more info
viewtopic.php?f=9&t=970

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: shellout
PostPosted: Tue Jul 12, 2011 5:46 pm  (#3) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16134
If you paste a list of all your programs you want to open in Shellout here i will create it for you. :)
make sure to include the path to the executable itself..
EXAMPLE
C:\Program Files\myprogram\myprogram.exe

_________________
Image


Top
 Post subject: Re: shellout
PostPosted: Tue Jul 12, 2011 9:39 pm  (#4) 
Offline
GimpChat Member

Joined: Apr 12, 2010
Posts: 5870
Basically to "add programs" you must modify the script, in case the bigger obstacle are only illogic fears ("script" are just words and number, and they may be opened with no risk with a text editor, and even mistakes in edit a script will not damage the computer, but only cause a error message when running the script.

But Rod may do the edit for you he only need the paths

To get the "PATHS" of your programs:
1 first find in the program files the "exe" that has the same name of the program
(i.e. Xnview - xnview.exe) that you want to add to shell out
2 then Right click on the exe, chose from there "propieties",
3 select & copy the path you will see there, adding the exe name at end :

EXAMPLE path for myprogram.exe:
if the path copied from "myprogram.exe" propiety is C:\Program Files\myprogram\ appending the exe name at the end you got C:\Program Files\myprogram\myprogram.exe

That is the right path

_________________
My 3D Gallery on Deviantart http://photocomix2.deviantart.com/
Main gallery http://www.flickriver.com/photos/photocomix-mandala/
Mandala and simmetry http://www.flickriver.com/photos/photocomix_mandala/

Image

Mrs Wilbress


Top
 Post subject: Re: shellout
PostPosted: Wed Jul 20, 2011 3:37 pm  (#5) 
Offline
GimpChat Member
User avatar

Joined: Jun 04, 2011
Posts: 254
Rod wrote:
If you paste a list of all your programs you want to open in Shellout here i will create it for you. :)
make sure to include the path to the executable itself..
EXAMPLE
C:\Program Files\myprogram\myprogram.exe


Attachments:
_2011-07-19_16-51-04.png
_2011-07-19_16-51-04.png [ 12.43 KiB | Viewed 3173 times ]
_2011-07-19_17-03-27.png
_2011-07-19_17-03-27.png [ 24.22 KiB | Viewed 3173 times ]

_________________
Image
Top
 Post subject: Re: shellout
PostPosted: Thu Jul 21, 2011 3:12 am  (#6) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16134
Here you go just copy the code and save it as ShellOut.py place it in the plugins folder, and you will find your filter under Filters/Call

#!/usr/bin/env python

'''
ShellOut.py
call an external program passing the active layer as a temp file.  Windows Only(?)

Author:
Rob Antonishen

Version:
0.4 modified to support many optional programs.

this script is modelled after the mm extern LabCurves trace plugin
by Michael Munzert http://www.mm-log.com/lab-curves-gimp

and thanks to the folds at gimp-chat has grown a bit ;)

License:

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

The GNU Public License is available at
http://www.gnu.org/copyleft/gpl.html

'''

from gimpfu import *
import shlex
import subprocess
import os, sys
import tempfile

#program list function (globals are evil)
def listcommands(option=None):
  #
  # Insert additonal shell command into this list.  They will show up in the drop menu in this order.
  # Use the syntax:
  # ["Menu Label", "command"]
  #
  # Where what gets executed is command fileame so include and flags needed in the command.
  programlist = [
  ["Blender", "\"C:\\Program Files\\blenderfoundation\\Blender.exe\""],
  ["Inkscape", "\"C:\\Program Files\\Inkscape\\inkscape.exe\""],
  ["Scribus", "\"C:\\Program Files\\Scribus 1.3.3.14\\scribus.exe\""],
  ["Delaboratory", "\"C:\\Program Files\\Delaboratory\\delaboratory.exe\""],
  ["Photivo", "\"C:\\Program Files\\Photivo\\photivo.exe\""],
  ["LuminanceHDR", "\"C:\\Program Files\\LuminanceHDR\\LuminanceHDR.exe\""],
  ["Raw Therapee", "\"C:\\Program Files\\Rawtherapee\\raw therapee.exe\""],
  ["Fotosketcher", "\"C:\\Program Files\\Fotosketcher\\fotosketcher.exe\""],
  ["Rawhide", "\"C:\\Program Files\\My-SpotSoftware\\Rawhide\\rawhide.exe\""],
  ["",""]
  ]
 
  if option == None: # no parameter return menu list, otherwise return the appropaiate array
    menulist = []
    for i in programlist:
      if i[0] != "":
        menulist.append(i[0])
    return menulist
  else:
    return programlist[option]
   

def plugin_main(image, drawable, visible, command):
  pdb.gimp_image_undo_group_start(image)
 
  # Copy so the save operations doesn't affect the original
  if visible == 0:
    # Save in temporary.  Note: empty user entered file name
    temp = pdb.gimp_image_get_active_drawable(image)
  else:
    # Get the current visible
    temp = pdb.gimp_layer_new_from_visible(image, image, "Visible")
    image.add_layer(temp, 0)

  buffer = pdb.gimp_edit_named_copy(temp, "ShellOutTemp")

  #save selection if one exists
  hassel = pdb.gimp_selection_is_empty(image) == 0
  if hassel:
    savedsel = pdb.gimp_selection_save(image)

  tempimage = pdb.gimp_edit_named_paste_as_new(buffer)
  pdb.gimp_buffer_delete(buffer)
  if not tempimage:
    raise RuntimeError
  pdb.gimp_image_undo_disable(tempimage)

  tempdrawable = pdb.gimp_image_get_active_layer(tempimage)

  # Use temp file names from gimp, it reflects the user's choices in gimp.rc
  # change as indicated if you always want to use the same temp file name
  #tempfilename = pdb.gimp_temp_name("png")
  tempfilename = os.path.join(tempfile.gettempdir(), "ShellOutTempFile.png")
 

  # !!! Note no run-mode first parameter, and user entered filename is empty string
  pdb.gimp_progress_set_text ("Saving a copy")
  pdb.file_png_save_defaults(tempimage, tempdrawable, tempfilename, tempfilename)

  # Command line - Change to match where you installed XnView
  progtorun = listcommands(command)
  command = progtorun[1] + " \"" + tempfilename + "\""
  args = shlex.split(command)

  # Invoke external command
  pdb.gimp_progress_set_text ("calling " + progtorun[0] + "...")
  pdb.gimp_progress_pulse()
  child = subprocess.Popen(args, shell=False)
  child.communicate()

  # put it as a new layer in the opened image
  try:
    newlayer2 = pdb.gimp_file_load_layer(tempimage, tempfilename)
  except:
    RuntimeError
  tempimage.add_layer(newlayer2,-1)
  buffer = pdb.gimp_edit_named_copy(newlayer2, "ShellOutTemp")

  if visible == 0:
    sel = pdb.gimp_edit_named_paste(drawable, buffer, 1)
  else:
    sel = pdb.gimp_edit_named_paste(temp, buffer, 1)

  pdb.gimp_buffer_delete(buffer)
  pdb.gimp_edit_clear(temp)   
  pdb.gimp_floating_sel_anchor(sel)

  #load up old selection
  if hassel:
    pdb.gimp_selection_load(savedsel)
    image.remove_channel(savedsel)
 
  # cleanup
  os.remove(tempfilename)  # delete the temporary file
  gimp.delete(tempimage)   # delete the temporary image

  # Note the new image is dirty in Gimp and the user will be asked to save before closing.
  pdb.gimp_image_undo_group_end(image)
  gimp.displays_flush()


register(
        "python_fu_shellout",
        "Call an external program",
        "Call an external program",
        "Rob Antonishen",
        "Copyright 2011 Rob Antonishen",
        "2011",
        "<Image>/Filters/Call/ShellOut...",
        "RGB*, GRAY*",
        [ (PF_RADIO, "visible", "Layer:", 1, (("new from visible", 1),("current layer",0))),
          (PF_OPTION,"command",("Program:"),0,listcommands())
        ],
        [],
        plugin_main,
        )

main()


Be sure and use Notepad ++ to copy and paste it in so it keeps the indentation correct.

_________________
Image


Top
 Post subject: Re: shellout
PostPosted: Thu Jul 21, 2011 3:35 am  (#7) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16134
By the way if you want to add more just copy one line and edit the areas in between the slashes.
Make sure to keep the double slashes as Windows likes those better. :)

Also be sure and check every program in the list to make sure it runs.
When you do your first test run if it doesn't show in the list it could be a few things.
1 - one of the programs windows doesn't like and the python script didn't execute correctly.
Solution - go through them all by adding a hash mark to the front of one line at a time and restart Gimp until you see it in the menu.Once you know which program line is the problem just keep the hash mark in the code.
# <--- example of a hash mark

2 - the code has been altered and something isn't written correctly.
Solution paste it here so someone can fix it.OR download the shellout script again and redo it.
Personally i keep an extra working one around just in case. :)

3 - the plugin is in the wrong place.
Solution - place the shellout.py script in the plugins folder.Restart Gimp.

Indecently the script works well in Gimp-2.7.3

_________________
Image


Top
 Post subject: Re: shellout
PostPosted: Thu Jul 21, 2011 5:45 pm  (#8) 
Offline
GimpChat Member
User avatar

Joined: Jun 04, 2011
Posts: 254
thanks rod your a life saver!

_________________
Image


Top
 Post subject: Re: shellout
PostPosted: Thu Jul 21, 2011 5:49 pm  (#9) 
Offline
Global Moderator
User avatar

Joined: May 16, 2010
Posts: 16134
Not a problem, glad to help. :)

_________________
Image


Top
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]



* Login  



Powered by phpBB3 © phpBB Group