Script: Rescue for dark or blown out images

Moderator: Kathy_9

Post Reply
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Script: Rescue for dark or blown out images

Post by gbotes »

I use this script to rescue me when I have images that are very dark or have very blown out shadows/highlights. It's not perfect, but if you have an image that's important (i.e. the only pic of Aunt Agatha eating cake on her 90th birthday), and you have to find a way to make it semi-usable, then this script might help you. Obviously when your image is poor, nothing will turn it into a masterpiece, and you may find lots of grain, noise, etc. but I still find this script helps me to get something I can use. It's based on my experience with Gimp. I use it on jpg images - RAW images have better ways for recovering shadows and highlights.

I'm posting it here as I'd like to encourage this forum to post and share scripts so we can all share and learn. Feel free to use and modify it, but if you do please share any additions, enhancements, etc. This script was recorded in PSP X8. I don't know enough yet to know what other versions of PSP it would run on.

Code: Select all

from PSPApp import *

def ScriptProperties():
    return {
        'Author': u'GBotes',
        'Copyright': u'2015. Share, use and change freely.',
        'Description': u'Rescue - Provides shadow and highlight recovery for images that are dark or very blown out',
        'Host': u'PaintShop Pro',
        'Host Version': u'18.00'
        }

def Do(Environment):
    # EnableOptimizedScriptUndo
    App.Do( Environment, 'EnableOptimizedScriptUndo', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })

    # LayerDuplicate
    App.Do( Environment, 'LayerDuplicate', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })

    # LayerDuplicate
    App.Do( Environment, 'LayerDuplicate', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })

    # SmartPhotoFix
    App.Do( Environment, 'SmartPhotoFix', {
            'UseGreyBalance': True, 

            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })

    # OneStepNoiseRemoval
    App.Do( Environment, 'OneStepNoiseRemoval', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })

    # BlackAndWhiteFilm
    App.Do( Environment, 'BlackAndWhiteFilm', {
            'FilterColor': None, 
            'Strength': None, 
            'Red': 0.333333, 
            'Green': 0.333333, 
            'Blue': 0.333333, 
            'Brightness': -100, 
            'Clarify': 100, 
            'SuggestSettings': False, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })

    # NegativeImage
    App.Do( Environment, 'NegativeImage', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })

    # MultiObjectProperties
    App.Do( Environment, 'MultiObjectProperties', {
            'General': {
                'Opacity': None, 
                'Name': None, 
                'IsVisible': None, 
                'IsTransparencyLocked': None, 
                'LinkSet': None, 
                'UseHighlight': None, 
                'PaletteHighlightColor': None, 
                'GroupLink': None, 
                'BlendMode': App.Constants.BlendMode.Overlay
                }, 
            'Effects': None, 
            'WorkingMode': 1, 
            'Path': None, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.AllAlways, 
                }
            })

    # MultiObjectProperties
    App.Do( Environment, 'MultiObjectProperties', {
            'General': {
                'Opacity': 50, 
                'Name': None, 
                'IsVisible': None, 
                'IsTransparencyLocked': None, 
                'LinkSet': None, 
                'UseHighlight': None, 
                'PaletteHighlightColor': None, 
                'GroupLink': None, 
                'BlendMode': None
                }, 
            'Effects': None, 
            'WorkingMode': 1, 
            'Path': None, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.AllAlways, 
                }
            })

    # Gaussian Blur
    App.Do( Environment, 'GaussianBlur', {
            'Radius': 5, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })

    # LayerMergeDown
    App.Do( Environment, 'LayerMergeDown', {
            'Path': None, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })

    # LayerDuplicate
    App.Do( Environment, 'LayerDuplicate', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })

    # Local Tone Mapping
    App.Do( Environment, 'LocalToneMap', {
            'Strength': 10, 
            'Block Size': 8, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })

    # Color Adjust HSL
    App.Do( Environment, 'ColorAdjustHSL', {
            'HSL': {
                'Colorize': False, 
                'Master': (0,10,0), 
                'MasterColorize': (0,0,0), 
                'Red': (0,0,0,315,345,15,45), 
                'Green': (0,0,0,75,105,135,165), 
                'Blue': (0,0,0,195,225,255,285), 
                'Cyan': (0,0,0,135,165,195,225), 
                'Magenta': (0,0,0,255,285,315,345), 
                'Yellow': (0,0,0,15,45,75,105)
                }, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })

    # HighPassSharpen
    App.Do( Environment, 'HighPassSharpen', {
            'BlendMode': App.Constants.BlendMode.HardLight, 
            'Strength': 50, 
            'Radius': 3, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })

    # LayerMergeDown
    App.Do( Environment, 'LayerMergeDown', {
            'Path': None, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                }
            })
Example (here's an image I found on the 'net):
dps003-underexposed-1.jpg
Here's the same image after running the script on it. From here, you could either run the script a second time (but it will be very grainy) or you could adjust the curves (my preference), or do some other editing:
dps003-adjusted-1.jpg
And here is what it looks like after the script and a simple curves adjustment. Interestingly, I noted that the image got bigger in kb size after each adjustment:
dps003-adjusted-curves-1.jpg
JoeB
Posts: 2778
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: Script: Rescue for dark or blown out images

Post by JoeB »

Thanks for the Christmas present for the group! :-)

I'm in full agreement that I hope people will use this forum not just for scripting help but for posting scripts that might be useful. That had been my hope when this sub-forum was first created. In the days of Jasc's PSP user interaction was very active in the newsgroups and there was a specific PSP Scripting group that had lots of great scripts created by users. They were often created at the request of others looking for a way to achieve something not easily done using individual tools in PSP.

Great work on that image, BTW!
Regards,

JoeB
Using PSP 2019 64bit
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Re: Script: Rescue for dark or blown out images

Post by gbotes »

JoeB wrote:Thanks for the Christmas present for the group! :-)

I'm in full agreement that I hope people will use this forum not just for scripting help but for posting scripts that might be useful. That had been my hope when this sub-forum was first created. In the days of Jasc's PSP user interaction was very active in the newsgroups and there was a specific PSP Scripting group that had lots of great scripts created by users. They were often created at the request of others looking for a way to achieve something not easily done using individual tools in PSP.

Great work on that image, BTW!
Thanks, JoeB! I suppose, understandably, most people would prefer to try to generate some income with their scripts and other resources. I always find that I learn and grow more if I do share, and I like to give back to the forum or group where the learning happens. Many users of this forum have been very kind and have helped me with questions or PSP issues, so I'd like to contribute something back, however small. Sadly I find that the available scripting resources are not very newbie friendly, and you need a bit of scripting or programming background to get started. This is something I keep hoping Corel will address in future.
JoeB
Posts: 2778
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: Script: Rescue for dark or blown out images

Post by JoeB »

gbotes wrote:Thanks, JoeB! I suppose, understandably, most people would prefer to try to generate some income with their scripts and other resources. I always find that I learn and grow more if I do share, and I like to give back to the forum or group where the learning happens. Many users of this forum have been very kind and have helped me with questions or PSP issues, so I'd like to contribute something back, however small. Sadly I find that the available scripting resources are not very newbie friendly, and you need a bit of scripting or programming background to get started. This is something I keep hoping Corel will address in future.
Python actually is a programming language - one of the 2 or 3 main ones used by Google, in fact - so it does have a learning curve which I don't think is something that Corel can really address. The ability in PSP to records scripts is likely as close as they can come to making it easy for those with no programming knowledge, and it works quite well for most stuff. For those of us without programming experience I find that a little help from existing resources and then checking out scripts done by more experienced scripters makes it relatively easy for me to figure out how to record and/or modify recorded or existing scripts to achieve a specific purpose that fits my needs. That, plus the help available from others here to push me in the right direction! :-)

While there are, of course, those who create lots of good scripts and do expect to get some financial return, many regular users often come up with a script or two (without doing enough of that work to justify trying to do so commercially) that does something very useful and don't mind sharing. Check out all of the free scripts available in the resources shown in the sticky at the top of this sub-forum and you'll see tons of stuff created by people who were members of the old Jasc groups. That scripting forum was actually quite active with contributions from many people in terms of providing scripts as well as scripting help and collaboration.
Regards,

JoeB
Using PSP 2019 64bit
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Re: Script: Rescue for dark or blown out images

Post by gbotes »

JoeB wrote:Python actually is a programming language - one of the 2 or 3 main ones used by Google, in fact - so it does have a learning curve which I don't think is something that Corel can really address. The ability in PSP to records scripts is likely as close as they can come to making it easy for those with no programming knowledge, and it works quite well for most stuff. For those of us without programming experience I find that a little help from existing resources and then checking out scripts done by more experienced scripters makes it relatively easy for me to figure out how to record and/or modify recorded or existing scripts to achieve a specific purpose that fits my needs. That, plus the help available from others here to push me in the right direction! :-)
Actually, I was thinking that what would really be nice is a scripting help resource similar to Corel's online help for PSP but dealing with scripting from beginner to advanced, and including example scripts dealing with the kinds of things photographers and graphic artists typically want to do, from beginner to advanced. SIgh. Maybe one day :)

Python is an excellent choice for scripting, so no complaints from me about that.
Cassel
Posts: 1587
Joined: Fri Oct 29, 2010 6:49 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16Gb
Corel programs: PSP 8 (JASC) to PSP 2023
Location: Canada
Contact:

Re: Script: Rescue for dark or blown out images

Post by Cassel »

If anyone is interested, Suz Shook has written a complete scripting course, that is now available in the Campus:

http://scrapbookcampus.com/paintshop-pr ... ng-course/

No, it is not free though.
Cassel
https://creationcassel.com/store
Specializing in PSP specific products: scripts and tubes

https://scrapbookcampus.com
for beginner and seasoned scrappers and designers and other PSP users
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Re: Script: Rescue for dark or blown out images

Post by gbotes »

Cassel wrote:If anyone is interested, Suz Shook has written a complete scripting course, that is now available in the Campus:

http://scrapbookcampus.com/paintshop-pr ... ng-course/

No, it is not free though.
Thanks for the link Cassel. Looks interesting but I'm not inclined to try courses "sight unseen". While Suz Shook has a good reputation on the 'net but I'd like to be able to to download and try out just one module without having to pay up front just ot get a feel for the qualifty of the course and her writing/teaching style. That would make me more comfortable. to spend the bucks as the ZAR to USD conversion is about 15 to one! :D
Cassel
Posts: 1587
Joined: Fri Oct 29, 2010 6:49 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16Gb
Corel programs: PSP 8 (JASC) to PSP 2023
Location: Canada
Contact:

Re: Script: Rescue for dark or blown out images

Post by Cassel »

I'd like to be able to to download and try out just one module without having to pay up front just ot get a feel for the qualifty of the course and her writing/teaching style.
Unfortunately, that is not my course, and i can't really share parts of it. Sorry.
I can tell you that it is the course i took, years ago, and got me into making scripts commercially. It is basic enough to bring a newbie up to par, but for more advanced coding, i have learned on my own, based on what i had learned with her course.
Cassel
https://creationcassel.com/store
Specializing in PSP specific products: scripts and tubes

https://scrapbookcampus.com
for beginner and seasoned scrappers and designers and other PSP users
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Re: Script: Rescue for dark or blown out images

Post by gbotes »

Of course, Cassel, it goes without saying that you cannot share parts of the course. I would not expect that. But you have answered some of my questions, for which I'm grateful. I'll start with learning about about Python first and then decide about the course later.
Post Reply