This prepares a multi-layer copy of a full-page newspaper article that will be excerpted.
The output file does get very large. A 4500 x 6200 jpg 4MB on disk, 27MB in RAM saves as a 65MB pspimage and 224MB in RAM (yes, 1/4 GB). Once you crop the image you'll definitely want to delete the bottom "Original" layer.
Let's say the article you want to show is in the bottom 2 inches.
After the user does all edits, the result will be the page top, a divider, a levels adjustment layer, and a little more than the bottom 2 inches.
The user must put the divider image in the clipboard. I have an image with two black wavy lines with white between them.
The script does not crop anything, it just does the prep work.
TASK: EXCERPT NEWSPAPER ARTICLE
1) Keeps page top
2) User positions user-defined divider image layer that indicates "removed"
3) The two bottom image layers are hidden
4) In the remaining VISIBLE image user erases everything BELOW divider
5) User makes next-to-bottom [NTB] image visible
6) User moves NTB up to only show BELOW the divider image the part
that will remain, i.e., if article is at bottom quarter, move up
so TOP of article is just BELOW divider. When moving up, it should
"slide under" the PAGE TOP *and* divider.
7a) User crops to the visible area and saves. -- OR --
7b) User selects the visible area, copies, pastes, saves as new image.
User can then edit the image, e.g., using the Levels layer to reduce
gray discoloration.
ACTIONS PERFORMED BY THE SCRIPT
Promote background to layer
Hide layer
Duplicate layer - this will be the visible article
Hide layer
Duplicate layer - this will be the visible top above the divider
Add Levels Adjustment layer
Paste as new layer the (divider) IMAGE currently in the clipboard
Move that up NEAR the top
Save as .pspimage with "cr-" PREFIX and FULL original name FOLLOWED by
".pspimage" (cr- means "cropped") e.g. cr-MyFile 04.jpg.pspimage
Code: Select all
from PSPApp import *
# TASK: EXCERPT NEWSPAPER ARTICLE
#
# 1) Keeps page top
# 2) User positions user-defined divider image layer that indicates "removed"
# 3) The two bottom image layers are hidden
# 4) In the remaining VISIBLE image user erases everything BELOW divider
# 5) User makes next-to-bottom [NTB] image visible
# 6) User moves NTB up to only show BELOW the divider image the part
# that will remain, i.e., if article is at bottom quarter, move up
# so TOP of article is just BELOW divider. When moving up, it should
# "slide under" the PAGE TOP *and* divider.
# 7a) User crops to the visible area and saves. -- OR --
# 7b) User selects the visible area, copies, pastes, saves as new image.
#
# User can then edit the image, e.g., using the Levels layer to reduce
# gray discoloration.
#
# ACTIONS PERFORMED BY THE SCRIPT
#
# Promote background to layer
# Hide layer
# Duplicate layer - this will be the visible article
# Hide layer
# Duplicate layer - this will be the visible top above the divider
# Add Levels Adjustment layer
# Paste as new layer the (divider) IMAGE currently in the clipboard
# Move that up NEAR the top
# Save as .pspimage with "cr-" PREFIX and FULL original name FOLLOWED by
# ".pspimage" (cr- means "cropped") e.g. cr-MyFile 04.jpg.pspimage
def ScriptProperties():
return {
'Author': u'Joseph Rick Reinckens',
'Copyright': u'no',
'Description': u'Add adjustment and wavy lines layers to news article, for excerpting',
'Host': u'PaintShop Pro',
'Host Version': u'19.00'
}
def Do(Environment):
path = App.TargetDocument.Name.rstrip(App.TargetDocument.Title)
filename = path + "cr-" + App.TargetDocument.Title + ".pspimage"
# EnableOptimizedScriptUndo
App.Do( Environment, 'EnableOptimizedScriptUndo', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((19,0,0),1),
'PreviewMode': 1,
'ScreenControl': 1
}
})
# ORIGINAL
# LayerPromoteBackground
App.Do( Environment, 'LayerPromoteBackground', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((19,0,0),1)
}
})
# RENAME TO 'Original'
# Layer Properties
App.Do( Environment, 'LayerProperties', {
'General': {
'Opacity': None,
'Name': u'Original',
'IsVisible': None,
'IsTransparencyLocked': None,
'LinkSet': None,
'UseHighlight': None,
'PaletteHighlightColor': None,
'GroupLink': None,
'BlendMode': None
},
'BlendRanges': None,
'Path': (0,0,[],False),
'ArtMediaTexture': None,
'Effects': None,
'BrightnessContrast': None,
'ChannelMixer': None,
'ColorBalance': None,
'CurveParams': None,
'HSL': None,
'Threshold': None,
'Levels': None,
'Posterize': None,
'Vibrancy': None,
'Overlay': None,
'LocalToneMapping': None,
'Invert': None,
'HistogramAdjustment': None,
'FillLightClarity': None,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Default,
'Version': ((19,0,0),1)
}
})
# HIDE ORIGINAL IMAGE
# LayerSetVisibility
App.Do( Environment, 'LayerSetVisibility', {
'Command': App.Constants.ShowCommands.Hide,
'Path': None,
'WorkingMode': 1,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Default,
'Version': ((19,0,0),1)
}
})
# ARTICLE
# LayerDuplicate
App.Do( Environment, 'LayerDuplicate', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((19,0,0),1)
}
})
# RENAME TO 'Article'
# Layer Properties
App.Do( Environment, 'LayerProperties', {
'General': {
'Opacity': None,
'Name': u'Article',
'IsVisible': None,
'IsTransparencyLocked': None,
'LinkSet': None,
'UseHighlight': None,
'PaletteHighlightColor': None,
'GroupLink': None,
'BlendMode': None
},
'BlendRanges': None,
'Path': (0,0,[],False),
'ArtMediaTexture': None,
'Effects': None,
'BrightnessContrast': None,
'ChannelMixer': None,
'ColorBalance': None,
'CurveParams': None,
'HSL': None,
'Threshold': None,
'Levels': None,
'Posterize': None,
'Vibrancy': None,
'Overlay': None,
'LocalToneMapping': None,
'Invert': None,
'HistogramAdjustment': None,
'FillLightClarity': None,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Default,
'Version': ((19,0,0),1)
}
})
# PAGE TOP
# LayerDuplicate
App.Do( Environment, 'LayerDuplicate', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((19,0,0),1)
}
})
# RENAME TO 'Page Top'
# Layer Properties
App.Do( Environment, 'LayerProperties', {
'General': {
'Opacity': None,
'Name': u'Page Top',
'IsVisible': None,
'IsTransparencyLocked': None,
'LinkSet': None,
'UseHighlight': None,
'PaletteHighlightColor': None,
'GroupLink': None,
'BlendMode': None
},
'BlendRanges': None,
'Path': (0,0,[],False),
'ArtMediaTexture': None,
'Effects': None,
'BrightnessContrast': None,
'ChannelMixer': None,
'ColorBalance': None,
'CurveParams': None,
'HSL': None,
'Threshold': None,
'Levels': None,
'Posterize': None,
'Vibrancy': None,
'Overlay': None,
'LocalToneMapping': None,
'Invert': None,
'HistogramAdjustment': None,
'FillLightClarity': None,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Default,
'Version': ((19,0,0),1)
}
})
# LayerSetVisibility
App.Do( Environment, 'LayerSetVisibility', {
'Command': App.Constants.ShowCommands.Show,
'Path': None,
'WorkingMode': 1,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Default,
'Version': ((19,0,0),1)
}
})
# ADD A LEVELS ADJUSTMENT LAYER because newspaper articles
# routinely get "greyed"
# Levels
App.Do( Environment, 'NewAdjustmentLayerLevels', {
'General': {
'Opacity': 100,
'Name': u'Levels 1',
'IsVisible': True,
'IsTransparencyLocked': False,
'LinkSet': 0,
'UseHighlight': False,
'PaletteHighlightColor': (255,255,64),
'GroupLink': True,
'BlendMode': App.Constants.BlendMode.Normal
},
'EffectLayer_Root': {
'WorkingMode': 0
},
'Levels': {
'RGB': (0,223,1.00648,0,255),
'Red': (0,255,1,0,255),
'Green': (0,255,1,0,255),
'Blue': (0,255,1,0,255),
'Clipping': 0
},
'Overlay': {
'Color': (255,0,0),
'Opacity': 50
},
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((19,0,0),1)
}
})
# PASTE AS NEW LAYER THE "SEPARATOR" IMAGE ALREADY IN THE CLIPBOARD
# PasteAsNewLayer
App.Do( Environment, 'PasteAsNewLayer', {
'CreateFromDropData': False,
'InsertPos': -1,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((19,0,0),1),
'PreviewMode': 1,
'ScreenControl': 1
}
})
# Layer Properties
App.Do( Environment, 'LayerProperties', {
'General': {
'Opacity': None,
'Name': u'Separator',
'IsVisible': None,
'IsTransparencyLocked': None,
'LinkSet': None,
'UseHighlight': None,
'PaletteHighlightColor': None,
'GroupLink': None,
'BlendMode': None
},
'BlendRanges': None,
'Path': (0,0,[],False),
'ArtMediaTexture': None,
'Effects': None,
'BrightnessContrast': None,
'ChannelMixer': None,
'ColorBalance': None,
'CurveParams': None,
'HSL': None,
'Threshold': None,
'Levels': None,
'Posterize': None,
'Vibrancy': None,
'Overlay': None,
'LocalToneMapping': None,
'Invert': None,
'HistogramAdjustment': None,
'FillLightClarity': None,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Default,
'Version': ((19,0,0),1)
}
})
# MOVE THE SEPARATOR NEAR THE PAGE TOP
# Move
App.Do( Environment, 'Mover', {
'Offset': (41,-2139),
'Object': App.Constants.LayerOrSelection.Layer,
'SelectPoint': (2143.5,3150.5),
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((19,0,0),1),
'PreviewMode': 1,
'ScreenControl': 1
}
})
# SAVE AS PSP IMAGE WITH NEW NAME
# FileSaveAs
App.Do( Environment, 'FileSaveAs', {
'Encoding': {
'PSP': {
'Compression': App.Constants.PspCompression.LZ77,
'Version': App.Constants.PspVersion.PSP18,
'EmbedICC': False
}
},
'FileName': filename,
'FileFormat': App.Constants.FileFormat.PSP,
'FormatDesc': u'PSPIMAGE',
'WorkingMode': 0,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'DialogPlacement': {
'ShowMaximized': False,
'Rect': ((0,0), 0, 0)
},
'AutoActionMode': App.Constants.AutoActionMode.AllAlways,
'Version': ((19,0,0),1),
'PreviewMode': 1,
'ScreenControl': 1
},
'DefaultProperties': []
})
