It is currently Fri Apr 19, 2024 1:05 pm


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
Author Message
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Sun Oct 18, 2015 10:35 am  (#281) 
Offline
GimpChat Member
User avatar

Joined: Jun 02, 2013
Posts: 2075
The Warrior wrote:
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 ]

Crap, I just noticed I put Launch in place of Unshake for the .bat file. I changed it, but now I get this error code:

Image

_________________
Image


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

Joined: Jun 02, 2013
Posts: 2075
Confusing myself, haha. It was supposed to be launch.bat. Still., it creates a new visible layer, and that's it.

_________________
Image


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

Joined: May 16, 2010
Posts: 14709
Location: USA
The Warrior wrote:
Confusing myself, haha. It was supposed to be launch.bat. Still., it creates a new visible layer, and that's it.


Can you copy the unshake.bat file code and the shellout code you are using here please?
Make sure you are using the correct path for your install of Unshake.

If it only adds a new layer you need to get the JAVA.EXE path correct in the bat file code.

_________________
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:51 am  (#284) 
Offline
GimpChat Member
User avatar

Joined: Jun 02, 2013
Posts: 2075
Rod wrote:
The Warrior wrote:
Confusing myself, haha. It was supposed to be launch.bat. Still., it creates a new visible layer, and that's it.


Can you copy the unshake.bat file code and the shellout code you are using here please?
Make sure you are using the correct path for your install of Unshake.

If it only adds a new layer you need to get the JAVA.EXE path correct in the bat file code.

Here's the entire code for the shellout plug in. Not sure if that's what you're asking me for. I only added the line you specified:

#!/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.7 fixed file save bug where all files were png regardless of extension
0.6 modified to allow for a returned layer that is a different size
than the saved layer for
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 = [
["Unshake", "\"C:\\Program Files\\Unshake\\Launch.bat\"", "png"],
["XNView", "\"C:\\PF\\XnView\\xnview.exe\"", "png"],
["MS Paint", "\"..\\..\\..\\..\\WINDOWS\\system32\\mspaint.exe\"", "bmp"],
["InPaint", "\"C:\\PF\\Inpaint\\Inpaint.exe\"", "png"],
#["Deep Paint", "\"C:\\Program Files\\DeepPaint\\deeppaint.exe\"", "jpg"],
#["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"],
["JDraw", "\"C:\\JavaJars\\jdraw.bat\"", "png"],
#["Vector Magic", "\"C:\\Program Files\\Vector Magic\\vmde.exe\"", "png"],
#["Photo Clinic", "\"C:\\MAGIX\\Photo_Clinic_45\\PhotoClinic.exe\"", "png"],
["Smilla Enlarger", "\"C:\\utils\\SmillaEnlarger\\SmillaEnlarger.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])


# !!! 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)

# 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:
drawable.resize(newlayer2.width,newlayer2.height,0,0)
sel = pdb.gimp_edit_named_paste(drawable, buffer, 1)
drawable.translate((tempdrawable.width-newlayer2.width)/2,(tempdrawable.height-newlayer2.height)/2)
else:
temp.resize(newlayer2.width,newlayer2.height,0,0)
sel = pdb.gimp_edit_named_paste(temp, buffer, 1)
temp.translate((tempdrawable.width-newlayer2.width)/2,(tempdrawable.height-newlayer2.height)/2)

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()

_________________
Image


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

Joined: Jun 02, 2013
Posts: 2075
Here's the Unshake .bat file code:

if exist "c:\jdk1.2.2\jre\bin\javaw.exe" path "c:\jdk1.2.2\jre\bin\javaw.exe"
if exist "c:\Program Files\JavaSoft\jre\1.2\bin\javaw.exe" path "c:\Program Files\JavaSoft\jre\1.2\bin"
if exist "c:\Program Files\JavaSoft\jre\1.3\bin\javaw.exe" path "c:\Program Files\JavaSoft\jre\1.3\bin"
if exist "c:\Program Files\JavaSoft\jre\1.3.1\bin\javaw.exe" path "c:\Program Files\JavaSoft\jre\1.3.1\bin"
if exist "c:\Program Files\JavaSoft\jre\1.3.2\bin\javaw.exe" path "c:\Program Files\JavaSoft\jre\1.3.2\bin"
if exist "c:\Program Files\JavaSoft\jre\1.4\bin\javaw.exe" path "c:\Program Files\JavaSoft\jre\1.4\bin"
if exist "c:\WINDOWS\javaw.exe" path "c:\WINDOWS";%PATH%
if exist "c:\WinNT\System32\javaw.exe" path "c:\WinNT\System32";%PATH%
path
java -Xmx512m -jar .\Unshake.jar source\*.*
exit

_________________
Image


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

Joined: May 16, 2010
Posts: 14709
Location: USA
["Unshake", "\"C:\\Program Files\\Unshake\\Launch.bat\"", "png"],


This will only work if you have JAVA installed in one of the directories the Launch.bat file looks for it in.
The best way to fix this is to create your OWN Unshake.bat file with the code i provided.
@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

Make sure your PATH to the JAVA executable and the Unshake.jar file is correct.

Then you will need to change the SHELLOUT code to reflect the directory you place the new Unshake.bat file in.This will normally be the same place as the Launch.bat file location.

_________________
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 11:04 am  (#287) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
You may need to COPY the JAVA folder to a new folder in C itself. Then point the bat file to it.

_________________
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 11:13 am  (#288) 
Offline
GimpChat Member
User avatar

Joined: Jun 02, 2013
Posts: 2075
Oh well, guess I'll stick to the old fashioned way. I'm not even close to a coder. I've tried, but still get the same result. It's not like I'll be using Unshake that much anyways, just thought it would be cool in Shellout. Thanks for your help, appreciate it.

_________________
Image


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Sun Oct 18, 2015 11:18 am  (#289) 
Offline
Global Moderator
User avatar

Joined: Nov 16, 2011
Posts: 5128
Location: Metro Vancouver, BC
The Warrior wrote:
Here's the entire code for the shellout plug in. Not sure if that's what you're asking me for. I only added the line you specified:...

You have 3 .bat files, in the list, that point to Java.
Check their path.
["Java Image Editor", "\"C:\\JavaJars\\imageeditor.bat\"", "png"],
["Java Mosaic", "\"C:\\JavaJars\\mosaic.bat\"", "png"],
["JDraw", "\"C:\\JavaJars\\jdraw.bat\"", "png"],

_________________
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: Mon Oct 19, 2015 6:55 am  (#290) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
Odinbc wrote:
The Warrior wrote:
Here's the entire code for the shellout plug in. Not sure if that's what you're asking me for. I only added the line you specified:...

You have 3 .bat files, in the list, that point to Java.
Check their path.
["Java Image Editor", "\"C:\\JavaJars\\imageeditor.bat\"", "png"],
["Java Mosaic", "\"C:\\JavaJars\\mosaic.bat\"", "png"],
["JDraw", "\"C:\\JavaJars\\jdraw.bat\"", "png"],


I have only had luck running Java files by copying the Java directory to my portables folder and pointing the bat to the executable there. I don't think java likes the directory name "Program Files" in the bat file. Hence the single string directory "Portables\Java\"

_________________
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: Mon Oct 19, 2015 7:02 am  (#291) 
Offline
GimpChat Member
User avatar

Joined: Jun 02, 2013
Posts: 2075
I tried everything shown, and tried other stuff. Still, the same thing happens. It creates a new layer, and that's it. I have not yet tried copying the Java to another folder. Will give that a shot tonight.

_________________
Image


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Fri Oct 23, 2015 5:45 am  (#292) 
Offline
GimpChat Member
User avatar

Joined: May 16, 2010
Posts: 14709
Location: USA
The Warrior wrote:
I tried everything shown, and tried other stuff. Still, the same thing happens. It creates a new layer, and that's it. I have not yet tried copying the Java to another folder. Will give that a shot tonight.

Sorry we couldn't get it working for you Warrior.

_________________
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: Fri Oct 23, 2015 7:02 am  (#293) 
Offline
GimpChat Member
User avatar

Joined: Jun 02, 2013
Posts: 2075
Rod wrote:
The Warrior wrote:
I tried everything shown, and tried other stuff. Still, the same thing happens. It creates a new layer, and that's it. I have not yet tried copying the Java to another folder. Will give that a shot tonight.

Sorry we couldn't get it working for you Warrior.

No biggie. I appreciate the help.

_________________
Image


Top
 Post subject: Re: ShellOut.py (was XNViewShell) - Call external programs
PostPosted: Fri Nov 26, 2021 7:31 am  (#294) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12516
Note, if you are using Windows, you need to use the double forward dash for each directly entry. Not sure what OS you are using, TW. :)

  ["DFine 2", "\"C:\\Program Files\\Google\\Nik Collection\\Dfine 2\\Dfine 2 (64-Bit)\\Dfine2.exe\"", "png"],


also, for java programs, I ended up having to use batch file calls; no longer do so but sample within Shellout shows this. :)

# ["Java Image Editor", "\"C:\\JavaJars\\imageeditor.bat\"", "png"],

_________________
Lyle

Psalm 109:8

Image


Top
 Post subject: Re: XNViewShell - and other Programs you can call with Gimp
PostPosted: Fri Aug 19, 2022 4:37 pm  (#295) 
Offline
GimpChat Member
User avatar

Joined: Jul 06, 2013
Posts: 2605
Location: California
Rod wrote:
Quote:
Rod
... posted 104 - new File version 1.0.3.2.(2011-03-29)
http://forums.getpaint.net/index.php?/t ... 011-01-28/

Oh that is too awesome - how did i miss this? - thanks MareroQ
[ Image ]


Quote:
I do wish some genius would just combine Inkscape and GIMP into one program

Oh how wonderful that would be! :)


The photoshop filters work with PDN. All I did was copy from gimp and put them in my effects folder for PDN.


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

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