It is currently Wed Apr 24, 2024 11:29 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 295 posts ]  Go to page Previous  1 ... 11, 12, 13, 14, 15  Next
Author Message
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Thu Dec 13, 2012 4:33 pm  (#261) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2424
No problems with shellout here PCLOS / Gimp 2.8.2 / wine 1.4.1 / xnview 1.98.2

From memory, I had problems with the versions after 0.5

This is the script I have installed

#!/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.5 file extension parameter in program list.
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", "ext"]
  #
  # Where what gets executed is command fileame so include and flags needed in the command.
  programlist = [
  ["XNView", "\"C:\\Program Files\\XnView\\xnview.exe\"", "png"],
  #["MS Paint", "\"C:\\WINDOWS\\system32\\mspaint.exe\"", "bmp"],
  #["Deep Paint", "\"C:\\Program Files\\DeepPaint\\DeepPaint.exe\"", "png"],
  #["Inkscape", "\"C:\\Program Files\\Inkscape\\inkscape.exe\"", "png"],
  #["PaintDOTNet", "\"C:\\Program Files\\Paint.NET\\PaintDotNet.exe\"", "png"],
  #["MyPaint", "\"C:\\Program Files\\MyPaint\\mypaint.exe\"", "png"],
  #["Photo Filter Factory", "\"C:\\Program Files\\Photo Filter Factory\\Photo Filter Factory.exe\"", "png"],
  #["Photo Pos Pro", "\"C:\\Program Files\\Photo Pos Pro\\Photo Pos Pro.exe\"", "png"],
  #["Java Image Editor", "\"C:\\JavaJars\\imageeditor.bat\"", "png"],
  #["Java Mosaic", "\"C:\\JavaJars\\mosaic.bat\"", "png"],
  #["Vector Magic", "\"C:\\Program Files\\Vector Magic\\vmde.exe\"", "png"],
  #["Photo Clinic", "\"C:\\MAGIX\\Photo_Clinic_45\\PhotoClinic.exe\"", "png"],
  #["","",""]
  ]
 
  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)
 
  #get the program to run and filetype.
  progtorun = listcommands(command)
 
  # 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(progtorun[2])
  #tempfilename = os.path.join(tempfile.gettempdir(), "ShellOutTempFile."+progtorun[2])
  tempwinfile = "C:\\windows\\temp\\tempfile.png"
  tempfilename = "/home/rich/.wine/drive_c/windows/temp/tempfile.png"

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

# Command line - Change to match where you installed XnView
  command = "/usr/bin/wine \"C:\\Program Files\\XnView\\xnview.exe\" \"" + tempwinfile + "\""
  gimp.message(command)
  args = shlex.split(command)

  # Build command line call
  #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/ShellOut...",
        "RGB*, GRAY*",
        [ (PF_RADIO, "visible", "Layer:", 1, (("new from visible", 1),("current layer",0))),
          (PF_OPTION,"command",("Program:"),0,listcommands())
        ],
        [],
        plugin_main,
        )

main()


sorry for posting all that, but I am short of time at the moment.

lines that need editing,
line 50 all the other apps are commented out
lines 109 110
lines 117

_________________
Image


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Thu Dec 13, 2012 10:37 pm  (#262) 
Offline
GimpChat Member

Joined: Dec 10, 2012
Posts: 32
Well, rich2005,

I made the changes you indicated, copied the script into Plugins, and it ran like a scalded dog.

I can't tell you how much I appreciate your posting the script, not to mention the fact that it works on my Xubuntu 12.04 (wine 1.4 & XnView 1.99.5).

I've got lots to learn.

Thanks to Rob A and rich2005.
What a great resource GimpChat is.

adam933


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Tue Dec 25, 2012 2:15 am  (#263) 
Offline
New Member

Joined: Dec 25, 2012
Posts: 1
Don't use Wine Xnview. You have XnviewMP native for Windows, Linux and Mac OS.
0.51 work greate on Ubuntu and Lion, I use both.


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Tue Dec 25, 2012 4:12 am  (#264) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2424
I agree that XnViewMP is a great light-weight image manager/browser. I use it myself. You can easily call up Gimp from within the application, a reverse of shell-out.

but

It does not support PS .8bf filters which I suspect will be the main reason for its use in this context.

_________________
Image


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Tue Mar 26, 2013 5:39 pm  (#265) 
Offline
GimpChat Member

Joined: Aug 06, 2012
Posts: 13
Anybody have any tips for getting shellout/gimp2.8.4(partha)x64/xnview to work on Win7x64?

My install of Partha's gimp is working fine. Latest XNView is installed and loads... When I launch shellout it has XNView selected and with either 'new from visible' or 'current layer' selected when I click ok, the slider shows it's saving to my temp directory, then XNview doesn't load after that completes.. If I watch the temp folder while it's creating the file/image, 'ShellOutTempFile.png' is there at zero and briefly becomes a file with data before it disappears...

Thanks!


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Tue Mar 26, 2013 8:57 pm  (#266) 
Offline
Script Coder
User avatar

Joined: Feb 18, 2011
Posts: 4827
Location: Bendigo Vic. Australia
In shellout did you check that the xnview path was correct as it might show the default path for an XP machine, this is my path for Xnview (at top of list)
All these paths should be checked and edited also place a '#' in front of any software you do not have

# Where what gets executed is command fileame so include and flags needed in the command.
  programlist = [
  ["XNView", "\"C:\\Program Files (x86)\\XnView\\xnview.exe\"", "png"],
  ["MS Paint", "\"C:\\WINDOWS\\system32\\mspaint.exe\"", "bmp"],
  #["Deep Paint", "\"C:\\Program Files\\DeepPaint\\deeppaint.exe\"", "jpg"],
  ["Inkscape", "\"C:\\Program Files (x86)\\Inkscape\\inkscape.exe\"", "png"],
  #["PaintDOTNet", "\"C:\\Program Files\\Paint.NET\\PaintDotNet.exe\"", "png"],
  ["MyPaint", "\"C:\\Program Files (x86)\\MyPaint\\mypaint.exe\"", "png"],
  #["Photo Filter Factory", "\"C:\\Program Files\\Photo Filter Factory\\Photo Filter Factory.exe\"", "png"],
  #["Photo Pos Pro", "\"C:\\Program Files\\Photo Pos Pro\\Photo Pos Pro.exe\"", "png"],
  #["Java Image Editor", "\"C:\\JavaJars\\imageeditor.bat\"", "png"],
  #["Java Mosaic", "\"C:\\JavaJars\\mosaic.bat\"", "png"],
  #["Vector Magic", "\"C:\\Program Files\\Vector Magic\\vmde.exe\"", "png"],
  #["Photo Clinic", "\"C:\\MAGIX\\Photo_Clinic_45\\PhotoClinic.exe\"", "png"],
  ["","",""]
  ]

_________________
Image
No matter how much you push the envelope, it'll still be stationery.


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Tue Mar 26, 2013 11:28 pm  (#267) 
Offline
GimpChat Member

Joined: Aug 06, 2012
Posts: 13
Graechan wrote:
In shellout did you check that the xnview path was correct


That did the trick thanks!


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Thu Nov 14, 2013 10:50 am  (#268) 
Offline
GimpChat Member

Joined: Nov 14, 2013
Posts: 101
Can anyone give an example of how to state the path to xnview in the script if you are on LINUX
as I find this thread confusing and Windows based.

_________________
using Gimp 2.10.8 with Linux on an ancient laptop


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Thu Nov 14, 2013 12:30 pm  (#269) 
Offline
Global Moderator
User avatar

Joined: Nov 16, 2011
Posts: 5128
Location: Metro Vancouver, BC
Born2BeMild wrote:
Can anyone give an example of how to state the path to xnview in the script if you are on LINUX
as I find this thread confusing and Windows based.
Check this post for Linux info.

_________________
Image
Gimp 2.8.18, Linux, median user
Gimp Chat Tutorials Index
Spirit Bear (Kermode)


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Thu Nov 14, 2013 2:27 pm  (#270) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2424
@Born2BeMild

Remember that XNview is a Windows application and as such runs under WINE.

then if you go back to post#262 the code there is for linux with a command line
command = "/usr/bin/wine \"C:\\Program Files\\XnView\\xnview.exe\" \"" + tempwinfile + "\""

my advice: make sure that XNview actually works with WINE in Linux. Latest WINE version 1.6 seems a little flakey.

_________________
Image


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Fri Nov 15, 2013 7:19 am  (#271) 
Offline
GimpChat Member

Joined: Nov 14, 2013
Posts: 101
yes I tried all that but it still doesn't work - dont know what else to try
xnview works fine under wine.
I get this error
Traceback (most recent call last):
  File "/usr/lib/gimp/2.0/python/gimpfu.py", line 699, in response
    dialog.res = run_script(params)
  File "/usr/lib/gimp/2.0/python/gimpfu.py", line 361, in run_script
    return apply(function, params)
  File "/home/dk/.gimp-2.8/plug-ins/XNViewShell.py", line 83, in plugin_main
    child = subprocess.Popen(args, shell=False)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory


and this is the path I have set
command = "\"C:\\Program Files\\portables\\XnView1.99.6\\xnview.exe\" \"" + tempfilename + "\""

_________________
using Gimp 2.10.8 with Linux on an ancient laptop


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Fri Nov 15, 2013 8:59 am  (#272) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2424
nope: that is the windoze part of it, xnview still has to be called from WINE (have a look at the code again in post#262 and the comment made about shellout version)

something like this near the beginning
------
# Where what gets executed is command fileame so include and flags needed in the command.
programlist = [
["XNView", "\"C:\\Program Files\\portables\\XnView1.99.6\\xnview.exe\"", "png"],
------
at line 110 - point it to your home & windows/temp
tempfilename = "/home/your_home_directory/.wine/drive_c/windows/temp/tempfile.png"

------
and further down the script at line 116
command = "\usr\bin\wine "C:\\Program Files\\portables\\XnView1.99.6\\xnview.exe\" \"" + tempfilename + "\""

-------

_________________
Image


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Fri Nov 15, 2013 9:11 am  (#273) 
Offline
GimpChat Member

Joined: Nov 14, 2013
Posts: 101
Hmm the last post I made was dumb - I can see that you would have to use wine at the front of the command. I have just tried that much That i have confused myself.
Yes I had already tried everything on post 262 and there was also a post suggesting I should use another script just called xnview but changing that script didn't work either.
Thats' why i find this whole thread confusing it's a mixture of suggestions for windows and linux and it would be better if it was two separate threads.
If there was a separate linux thread I could have seen someone els'es script and just slightly changed it to reflect my paths instead of trying to use a script for windows - changing it doesn't work for me.
I give up thanks for the help

_________________
using Gimp 2.10.8 with Linux on an ancient laptop


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Sat Aug 15, 2015 4:00 am  (#274) 
Offline
GimpChat Member
User avatar

Joined: Aug 13, 2015
Posts: 312
Location: Somewhere between lost and found.
I haven’t read this whole topic so I apologize if I am restating something, but xnview is now natively available for Linux. I just installed it tonight on LinuxMint 17.1.

_________________
The answer was 42. The question is long forgotten. The computer that solved it is now destroyed.
The MK-2 has been built. Should this be the next question?
(Solve if you can ... ;) )
Image


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Sat Aug 15, 2015 4:21 am  (#275) 
Offline
GimpChat Member

Joined: Mar 04, 2011
Posts: 2424
Unfortunately when it was packaged, the package was incorrectly named.

What you get is XnViewMP (xnview multi platform) an excellent graphics file viewer / organiser / converter. Well worth installing.

Attachment:
xnviewmp.jpg
xnviewmp.jpg [ 87.49 KiB | Viewed 13631 times ]


What is not there is support for PS .8bf filters.

Back to the old windoze xnview + WINE

_________________
Image


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Sat Aug 15, 2015 9:06 am  (#276) 
Offline
GimpChat Member
User avatar

Joined: Aug 13, 2015
Posts: 312
Location: Somewhere between lost and found.
grrrrrrrrrrrrrrr............................

_________________
The answer was 42. The question is long forgotten. The computer that solved it is now destroyed.
The MK-2 has been built. Should this be the next question?
(Solve if you can ... ;) )
Image


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Sat Oct 17, 2015 11:36 pm  (#277) 
Offline
GimpChat Member
User avatar

Joined: Jun 02, 2013
Posts: 2075
Way too lazy to read through this, but is there anyway to add the program "Unshake" to shellout?

_________________
Image


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Sun Oct 18, 2015 8:09 am  (#278) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
The Warrior wrote:
Way too lazy to read through this, but is there anyway to add the program "Unshake" to shellout?

Yes. When you open the Unshake folder you will see a file named "Launch.bat" point Shellout to this executable file like such.

  ["Unshake", "\"C:\\Portables\\Unshake\\Launch.bat\"", "png"],


Be sure to point to the correct folder destination path. Mine just happens to be c:\\Portables\\Unshake.
DON'T forget to double slash or Shellout won't find the directory.

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Sun Oct 18, 2015 8:34 am  (#279) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
OR if you have Java installed elsewhere use a new bat file and point shellout to it instead.
For instance i have Java installed in my portables directory.
The shellout file.
  ["Unshake", "\"C:\\Portables\\Unshake\\Unshake.bat\"", "png"],


And the bat file.
@echo off
echo *** Do Not Close this Window ***
echo Temp File: %1
"C:\Portables\Java\jre7\bin\java.exe" -jar c:\Portables\Unshake\Unshake.jar %1

Image

_________________
Image
Edmund Burke nailed it when he said, "The only thing necessary for the triumph of evil is for good men to do nothing."


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Sun Oct 18, 2015 10:31 am  (#280) 
Offline
GimpChat Member
User avatar

Joined: Jun 02, 2013
Posts: 2075
Rod wrote:
The Warrior wrote:
Way too lazy to read through this, but is there anyway to add the program "Unshake" to shellout?

Yes. When you open the Unshake folder you will see a file named "Launch.bat" point Shellout to this executable file like such.

  ["Unshake", "\"C:\\Portables\\Unshake\\Launch.bat\"", "png"],


Be sure to point to the correct folder destination path. Mine just happens to be c:\\Portables\\Unshake.
DON'T forget to double slash or Shellout won't find the directory.

It seems to have found it, but when I activate Unshake through Shellout, it makes a new visible layer, then that's all it does. The Unshake program itself isn't showing up. Here's the code I added:

Image

_________________
Image


Top
Post new topic Reply to topic  [ 295 posts ]  Go to page Previous  1 ... 11, 12, 13, 14, 15  Next

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Extended version ShellOut.

1

No new posts Attachment(s) How to call a python filter to run interactively

10



* Login  



Powered by phpBB3 © phpBB Group