Is there anything similar to Gimp's ShellOut script for PSP?

Moderator: Kathy_9

Post Reply
migf1
Posts: 485
Joined: Fri Apr 03, 2020 3:09 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit

Is there anything similar to Gimp's ShellOut script for PSP?

Post by migf1 »

Hi guys,

I just installed the free Nik Collection suite in Gimp, via the ShellOut script (I already have Nik Collection in PSP).

I was thrilled by the simplicity of the concept behind the ShellOut.py script, and I was wondering if there is something similar for PSP, or if it can be ported for PSP.

Gimp does NOT understand Ps .8bf plugins format (PSP does), but with ShellOut it doesn't have to.

When ShellOut is called from within Gimp's Filters menu, it presents a dialog with 2 options:
1. A 2-fold radio option: [As a new layer] OR [On current layer]
2. A drop-down list, so the user can select which program will be executed

Like so: http://prntscr.com/t56qz0

Which program will appear in the drop-down list, is defined inside ShellOut's python source-code. For each program, 3 things are defined:
* The name to be appeared in the drop-down list
* The full-path of the program in the user hard-disk
* The image extension to be used for that program (.png/.jpg/etc)

Here is an example of how I've tweaked the relative function for the Nik Collection:

Code: Select all

...
#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 = [
  # Nik Collection
  ["NC DFine 2", "\"C:\\Program Files\\DxO\\Nik Collection\\Dfine 2\\Dfine2.exe\"", "png"],
  ["NC Sharpener Pro 3", "\"C:\\Program Files\\DxO\\Nik Collection\\Sharpener Pro 3\\SHP3OS.exe\"", "png"],
  ["NC Viveza 2", "\"C:\\Program Files\\DxO\\Nik Collection\\Viveza 2\\Viveza 2.exe\"", "png"],
  ["NC Color Efex Pro 4", "\"C:\\Program Files\\DxO\\Nik Collection\\Color Efex Pro 4\\Color Efex Pro 4.exe\"", "png"],  # was: jpg
  ["NC Analog Efex Pro 2", "\"C:\\Program Files\\DxO\\Nik Collection\\Analog Efex Pro 2\\Analog Efex Pro 2.exe\"", "png"],  # was: jpg
  ["NC HDR Efex Pro 2", "\"C:\\Program Files\\DxO\\Nik Collection\\HDR Efex Pro 2\\HDR Efex Pro 2.exe\"", "png"],  # was: jpg
  ["NC Silver Efex Pro 2", "\"C:\\Program Files\\DxO\\Nik Collection\\Silver Efex Pro 2\\Silver Efex Pro 2.exe\"", "png"],  # was: jpg
  ["","",""]
  ]
...
Back in Gimp, once the desired options are selected in the dialog, it runs the selected program, sending it as input a fixed-name image which ShellOut creates in the system's Temp folder (%temp% on Windows). The fixed-name image is called: ShellOutTempFile + the defined extension (.png for the example above). When the external program is done processing the sent image (%temp%\ShellOutTempFile.png), the script loads it back to Gimp, either on the current layer or on a new layer (depending on the user selection in the initial dialog).

I find this both simple and brilliant. The nice thing about this is that even if the the external program is not configured to auto-save on exit, the user can manually Save the changes before closing the program (the filename is already known to the external program, because ShellOut launched it with that as an input argument: %temp%\ShellOutTempFile.png).

So what do you guys think? Is it possible to have something like that in PSP too?

It would speed up so much workflows that involve processing an image in more than 1 program.
Good Unofficial PaintShop Pro Tutorials: Creation CasselMake Shop ProHEC Image EditingLeviFiction PSP Basics
(plus my own Gimp & Stuff)
JoeB
Posts: 2662
Joined: Fri Mar 28, 2008 10:04 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: LENOVO 4524PE4 ThinkCentre M91p
processor: 3.10 gigahertz Intel Quad Core i5-2400
ram: 8 GB
Hard_Drive_Capacity: 4.6 TB
Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
Location: Canada

Re: Is there anything similar to Gimp's ShellOut script for

Post by JoeB »

:wink: Similar:

https://forum.corel.com/viewtopic.php?f ... ts#p364735

And now that I've seen the Gimp script perhaps @LeviFiction might be able to design a front end to a Nik script that would allow the script to contain all of the programs a person would want to call and let a person select the program from the front end menu they way the Gimp script does. :?: :wink:
Regards,

JoeB
Using PSP 2019 64bit
migf1
Posts: 485
Joined: Fri Apr 03, 2020 3:09 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit

Re: Is there anything similar to Gimp's ShellOut script for

Post by migf1 »

You just made me smile Joe! Thank you very much!

I have a question, I want the temp-file to be saved as "png" but I see that the script defaults to "jpg" and falls-back to "tif" for everything else. So I want to insert 1 more else statement, specifically for png, but I do not know how to tell it to NOT compress it. What are the ENCODING properties for png?

Code: Select all

    # Save image as temporary file
    if tmpFileExt == '.jpg':
        ...
    elif tmpFileExt == '.png':
		App.Do( Environment, 'FileSaveCopyAs', {
				'Encoding': {
					'PNG': {
						### !!! WHAT SHOULD I PUT HERE? !!! ###
						}
					}, 
				'FileName': tmpFilename, 
				'FileFormat': App.Constants.FileFormat.JPG, 
				'FormatDesc': u'JPG JPEG ', 
				'WorkingMode': 0, 
				'GeneralSettings': {
					'ExecutionMode': App.Constants.ExecutionMode.Silent, 
					'AutoActionMode': App.Constants.AutoActionMode.Match, 
					'Version': ((14,0,0),1)
					}, 
				'DefaultProperties': []
				})
    else:
		App.Do( Environment, 'FileSaveCopyAs', {
				'Encoding': {
					'TIF': {
						'Compression': App.Constants.TiffCompression.LZW, 
						'Channels': App.Constants.ColorChannels.RGB, 
						'EmbedTIFICC': True
						}
					}, 
				'FileName': tmpFilename, 
				'FileFormat': App.Constants.FileFormat.TIF, 
				'FormatDesc': u'TIF Tagged Image', 
				'WorkingMode': 0, 
				'GeneralSettings': {
					'ExecutionMode': App.Constants.ExecutionMode.Silent, 
					'AutoActionMode': App.Constants.AutoActionMode.Match, 
					'Version': ((14,0,0),1)
					}, 
				'DefaultProperties': []
				})
...
Good Unofficial PaintShop Pro Tutorials: Creation CasselMake Shop ProHEC Image EditingLeviFiction PSP Basics
(plus my own Gimp & Stuff)
LeviFiction
Advisor
Posts: 5984
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Alienware M17xR4
processor: Intel Core i7-3630QM CPU - 2_40GH
ram: 6 GB
Video Card: NVIDIA GeForce GTX 660M
sound_card: Sound Blaster Recon3Di
Hard_Drive_Capacity: 500GB
Corel programs: PSP: 8, 9, X, XI, X2, X8,X9, 2018, 2019
Location: USA

Re: Is there anything similar to Gimp's ShellOut script for

Post by LeviFiction »

Record a script that saves an uncompressed PNG, then use the encoding from that script.

EDIT: If you saw this before I added the code, sorry. My mouse is being a butt and I clicked submit before I was ready. :P

It technically doesn't give a "non-compressed" option but I think these settings should work just fine.

Code: Select all

                'PNG': {
                    'Interlaced': False, 
                    'OptimizedPalette': False, 
                    'AlphaChannel': True
                    }
migf1
Posts: 485
Joined: Fri Apr 03, 2020 3:09 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit

Re: Is there anything similar to Gimp's ShellOut script for

Post by migf1 »

Oh, I should have thought of that (recording a test script, that is)!

But I'll go with your code first, Levi! Thank you very much!
Good Unofficial PaintShop Pro Tutorials: Creation CasselMake Shop ProHEC Image EditingLeviFiction PSP Basics
(plus my own Gimp & Stuff)
migf1
Posts: 485
Joined: Fri Apr 03, 2020 3:09 pm
operating_system: Windows 8.1
System_Drive: C
32bit or 64bit: 64 Bit

Re: Is there anything similar to Gimp's ShellOut script for

Post by migf1 »

It worked like a charm!

Code: Select all

...
   elif tmpFileExt == '.png':
		App.Do( Environment, 'FileSaveCopyAs', {
				'Encoding': {
					'PNG': {
                        'Interlaced': False,
                        'OptimizedPalette': False,
                        'AlphaChannel': True
						}
					}, 
				'FileName': tmpFilename, 
				'FileFormat': App.Constants.FileFormat.JPG, 
				'FormatDesc': u'PNG Portable Network Graphics', 
				'WorkingMode': 0, 
				'GeneralSettings': {
					'ExecutionMode': App.Constants.ExecutionMode.Silent, 
					'AutoActionMode': App.Constants.AutoActionMode.Match, 
					'Version': ((14,0,0),1)
					}, 
				'DefaultProperties': []
				})
...
I tried recording a script too Levi, you had it exactly right! The only difference was that my recorded script set the AlphaChannel to False, I guess because I saved an image without transparency, but in general I do want it to always save with an Alpha channel. Thanks again!

Btw, I also changed the save path, in line 35 from:

Code: Select all

tmpFilename = os.path.expanduser("~\\Documents\\PspShellOut_temp") + tmpFileExt
to:

Code: Select all

tmpFilename = os.path.expanduser("~\\AppData\\Local\\Temp\\PspShellOut_temp") + tmpFileExt
to keep the save folder consistent with Gimp's ShellOut, so I do not have to manually change it every time I save the pic in the external program, when it is called from PSP and from Gimp.

PS. I am still smiling! Thank you very much guys!

PS2 (Irrelevant): Btw, if you are using Gimp check out my latest themes :) (the funny thing is that I rarely use Gimp, if ever LOL)
Good Unofficial PaintShop Pro Tutorials: Creation CasselMake Shop ProHEC Image EditingLeviFiction PSP Basics
(plus my own Gimp & Stuff)
Post Reply