'Copyright': 'Copyright (C) 2002-2003, Jasc Software Inc., All Rights Reserved. Permission to create derivate works of this script is granted provided this copyright notice is included',
'Description': 'Place a caption on an image by expanding the canvas and placing the caption below the image.',
'Host': 'Paint Shop Pro',
'Host Version': '8.00'
}
FontName = 'Times New Roman' # font name that will be used by the text
ExpandEdges = 0.1 # expand top, left and right by 10%
ExpandBottom = 0.15 # expand bottom by 15%
def Do(Environment):
''' Add a caption by doing the following steps:
(Thanks to Angela Cable for advice on artistic aspect of this)
1. Prompt the user for the caption. If they press cancel abort
2. Select the bottommost layer
3. If we are starting on a background layer, promote it to a full layer. To keep
things straight,rename the layer to "Image"
4. Add a new empty layer. Call it Page Surface.
5. Arrange the Page Surface to the bottom
6. Increase the canvas size by 10% on the left, right and top,
and by 15% on the bottom.
7. Move the Page Surface layer into a layer group. Call the group Album Page
8. Select the Page Surface layer
9. Flood fill it with white.
10. Using the backdrop texture and a 192 grey, flood fill it again.
11. Select the image layer again.
12. Add drop shadow on a new layer.
13. Arrange the layer into the Album page group
14. Create a vector layer
15. Place the caption text the user entered at the beginning on the image.
Font used is set in the FontName variable
16. Select the image layer again
When done, the original layer is unchanged, and all of the new layers are placed
inside of a layer group. The canvas size is changed however.
'''
if JascUtils.RequireADoc( Environment ) == App.Constants.Boolean.false:
return
# save off the target doc before we do anything
Target = App.TargetDocument
# we work with percentages for a number of things, and the expectation is that the
# text should be visible - lets not support any image with a dimension less than 200
if Target.Height < 200 or Target.Width < 200:
App.Do( Environment, 'MsgBox', {
'Buttons': App.Constants.MsgButtons.OK,
'Icon': App.Constants.MsgIcons.Stop,
'Text': 'The current image is too small to caption - it must be at least 200x200.',
})
return
# if we are running on something that is not a flat image, suggest
# that they flatten before continuing
if JascUtils.GetLayerCount( Environment, Target ) != 1:
result = App.Do( Environment, 'MsgBox', {
'Buttons': App.Constants.MsgButtons.YesNo,
'Icon': App.Constants.MsgIcons.Question,
'Text': 'The current image has multiple layers. This may lead to odd results.\n'
'We suggest flattening the image before continuing. Do you wish to flatten?'
})
if result == 1: # yes
App.Do( Environment, 'LayerMergeAll' )
DefaultCaption = Target.Title
ExtensionPos = DefaultCaption.rfind( '.' )
if ExtensionPos != -1:
DefaultCaption = DefaultCaption[ : ExtensionPos ]
# prompt for the caption at the very beginning - if they press cancel in the dialog we
# can return before any changes are made to the image
# now prompt the user for the caption to user
Result = App.Do( Environment, 'GetString', {
'DefaultText': DefaultCaption,
'DialogTitle': 'Enter Image Caption',
'Prompt': 'Enter a caption for the image. This will be below the image and centered.',