''' Version 1.01 August 7, 2005. This script extracts EXIF data from the active document and places it at the lower left corner of the image in a newly created black border. The caption contains the camera make/model number, aperture, exposure time, ISO and focal length. This does require that the image contain this information to being with - if no EXIF data is found it puts up a message box and returns without changing the image. The EXIF info text is about 450 pixels wide. If the original image is less then 450 pixels wide, the script will put up a message box and return without changing the image. The text is placed at the bottom left corner of a new image border. The border color can be changed in the "Create border section" below and is marked with an arrow. The border width can also be changed in the same section. EXIF text color can be changed in the "Text" section below and is also marked. The script can run from the batch mode on the file menu if desired (File > Batch > Process...). Take note of the options in the batch process so as not to overwrite the original files. This script is a combination of two scripts. The first part is the script generated from within PSP by recording the "Image > Add borders..." function. The second part is an existing but modified PSP EXIF script that now includes more data and places the text line at the left side. The scaling functionality of the second script is removed since we are working with fixed borders here. Some rearranging was done to make it all work. Nand.(n.romijn@gmail.com) ''' from JascApp import * import string import JascUtils def ScriptProperties(): return { 'Author': u'Jasc Software, Inc.', 'Copyright': u'Copyright (c) 2002-2004 Jasc Software, Inc. All rights reserved.', 'Description': "Put EXIF camera and exposure information at the bottom of the image.", 'Host': u'Paint Shop Pro 9', 'Host Version': u'9.00', } # Begin Translatable Strings. ImageTooSmallMsg = "The current image is too small to caption - it must be at least 450 pixels wide." NoEXIFData = "No EXIF data found on the current image." ExposureMsg = ", f/%g, %ss, ISO%s, fl%s" CaptionBackground = "Caption Background" EXIFCaption = "EXIF Caption" EXIFText = "EXIF Text" CaptionFontName = "Comic Sans MS" Chars = " second " # End Translatable Strings. Target = App.TargetDocument TextSize = int(14) #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Text size 14 pixels def Do(Environment): if JascUtils.RequireADoc( Environment ) == App.Constants.Boolean.false: return # Return unchanged image if image is to small to fit EXIF text line. That is 450 pixels minimum. if Target.Width < 450: App.Do( Environment, 'MsgBox', { 'Buttons': App.Constants.MsgButtons.OK, 'Icon': App.Constants.MsgIcons.Stop, 'Text': ImageTooSmallMsg, }) return # First extract the EXIF data - if we can't find any just return without changing the image. ImageInfo = App.Do( Environment, 'ReturnImageInfo', {'GeneralSettings': {'Version': ((9,0,0),1) }} ) if ImageInfo['ExifMake'] == '' or ImageInfo['ExifModel'] == '' or\ ImageInfo['ExifFNumber' ] == '' or ImageInfo['ExifExposureTime'] == '': App.Do(Environment, 'MsgBox', { 'Buttons': App.Constants.MsgButtons.OK, 'Icon': App.Constants.MsgIcons.Stop, 'Text': NoEXIFData, 'GeneralSettings': {'Version': ((9,0,0),1) } }) return # Add borders. All borders are a fixed 40 black pixels. App.Do( Environment, 'AddBorders', { 'Bottom': int(40), #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Border size 'Left': int(40), 'Right': int(40), 'Symmetric': True, 'Top': int(40), 'Color': (0,0,0), #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Border color 'DimUnits': App.Constants.UnitsOfMeasure.Pixels, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Default, 'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((9,0,1),1) } }) # Assemble the camera string by concatenating the camera make and model. Some camera # manufacturers have the barbaric practice of CAPITALIZING everything in their make and model # strings, so convert it to initial caps only for a more civilized appearance. CaptionTextCamera = unicode(string.capwords( ImageInfo['ExifMake'] + ' ' + ImageInfo[ 'ExifModel'])) # Now assemble exposure information by using the aperture and exposure and strip the string " second " # in order to shorten the string. Aperture = float(ImageInfo['ExifFNumber']) CaptionTextExposure = ExposureMsg % (Aperture, ImageInfo['ExifExposureTime']. rstrip(Chars),\ ImageInfo['ExifISOSpeed'].strip(),(ImageInfo['ExifFocalLength'])) # Select the raster layer so that the vector layer gets created above it. App.Do( Environment, 'SelectLayer', { 'Path': (0,0,[1],App.Constants.Boolean.false), 'GeneralSettings': {'Version': ((9,0,0),1) } }) # Now create a vector layer to put text on - creating the layer will make it active. App.Do( Environment, 'NewVectorLayer', { 'General': { 'Opacity': 100, 'Name': EXIFText, }, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'Version': ((9,0,0),1) } }) # Text # Place the line of text 40 pixels from the left and 14 pixels up.(the hight of the image minus 14) TextPlacementLine1 = (40, App.TargetDocument.Height - (14) ) App.Do( Environment, 'TextEx', { 'Visibility': True, 'CreateAs': App.Constants.CreateAs.Vector, 'TextFlow': App.Constants.TextFlow.HorizontalDown, 'TextType': App.Constants.TextType.TextBase, 'AutoKern': False, 'AntialiasStyle': App.Constants.AntialiasEx.Smooth, 'Fill': { 'Color': (255,255,255), #<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Text color 'Pattern': None, 'Gradient': None, 'Texture': None }, 'Font': CaptionFontName, 'PointSize': TextSize, 'Start': TextPlacementLine1, 'Stroke': None, 'LineStyle': None, 'LineWidth':0, 'SetText': App.Constants.Justify.Left, 'Characters': CaptionTextCamera + CaptionTextExposure, 'GeneralSettings': { 'ExecutionMode': App.Constants.ExecutionMode.Silent, 'AutoActionMode': App.Constants.AutoActionMode.Match, 'Version': ((9,0,0),1) } }) # The world is flat. App.Do( Environment, 'LayerMergeAll', { 'GeneralSettings': {'Version': ((9,0,0),1) } }) # All done!