Is it possible to batch add different text to mult photos?
Moderator: Kathy_9
-
summersond
- Posts: 10
- Joined: Thu Jul 10, 2014 5:31 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- Hard_Drive_Capacity: 2tb
Is it possible to batch add different text to mult photos?
I have a job of 400 photos that I need to add different text to each one. Is there a way to do this in a batch so I dont kill myself cutting and pasting 400 times?
Thanks!
Thanks!
-
summersond
- Posts: 10
- Joined: Thu Jul 10, 2014 5:31 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- Hard_Drive_Capacity: 2tb
Re: Is it possible to batch add different text to mult photo
I should also add that the text lines are in an external file so I would need a way to import each new line (via delimiter) to each new slide.
-
Radim
- Posts: 712
- Joined: Mon Nov 01, 2010 5:54 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- ram: 4GB
- Monitor/Display Make & Model: 27 inch
Re: Is it possible to batch add different text to mult photo
Yes, with scripting.
Look in PSP X6 on scripts - Simple Caption and EXIFCaptioning.
Below is simple recorded and edited script, in loads captions from external text file and first apply to image.
Question is how to or according what to select particular line/caption and use it in batch processing... that's the question.
Look in PSP X6 on scripts - Simple Caption and EXIFCaptioning.
Below is simple recorded and edited script, in loads captions from external text file and first apply to image.
Question is how to or according what to select particular line/caption and use it in batch processing... that's the question.
Code: Select all
from PSPApp import *
import fileinput
def ScriptProperties():
return {
'Author': u'Radim',
'Copyright': u'',
'Description': u'',
'Host': u'PaintShop Pro',
'Host Version': u'16.00'
}
def Do(Environment):
# do load Captions from text file; one line one caption
captions = []
inpFile = open( "C:\\Users\\Admin\\Dokumenty\\textlines.txt", "r" ) # path to your file
for line in inpFile:
captions.append( line.strip() ) # remove '\n' from end
inpFile.close()
print "1st caption is: ",captions[0] # only to see that we something loaded
# Text
App.Do( Environment, 'TextEx', {
'Visibility': True,
'CreateAs': App.Constants.CreateAs.Vector,
'Start': (25,49),
'TextFlow': App.Constants.TextFlow.HorizontalDown,
'TextType': App.Constants.TextType.TextBase,
'Matrix': [
1,
0,
0,
0,
1,
0,
0,
0,
1
],
'AutoKern': True,
'Kerning': 0,
'Tracking': 0,
'Leading': 0,
'Font': u'Verdana',
'PointSize': 30,
'Italic': False,
'Bold': True,
'Underline': False,
'Strikethru': False,
'AntialiasStyle': App.Constants.AntialiasEx.Smooth,
'WarpText': True,
'SetText': App.Constants.Justify.Left,
'Fill': {
'Color': (254,59,28),
'Pattern': None,
'Gradient': None,
'Texture': None,
'Art': None
},
'Stroke': {
'Color': (253,254,20),
'Pattern': None,
'Gradient': None,
'Texture': None,
'Art': None
},
'LineWidth': 1,
'LineStyle': {
'Name': u'',
'FirstCap': (u'',0.25,0.25),
'LastCap': (u'',0.25,0.25),
'FirstSegCap': (u'',0.25,0.25),
'LastSegCap': (u'',0.25,0.25),
'UseSegmentCaps': False,
'Segments': None
},
'Join': App.Constants.JointStyle.Miter,
'MiterLimit': 10,
'Characters': captions[0],
'Strings': None,
'TextTarget': (0,0,[1],True),
'PathTarget': None,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((16,0,0),1)
}
})
# Vector Align Horizontally in Center
App.Do( Environment, 'VectorAlignHorzCenter', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((16,0,0),1)
}
})
# Vector Align Bottom
App.Do( Environment, 'VectorAlignBottom', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((16,0,0),1)
}
})
Last edited by Radim on Fri Jul 11, 2014 4:18 pm, edited 2 times in total.
-
Radim
- Posts: 712
- Joined: Mon Nov 01, 2010 5:54 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- ram: 4GB
- Monitor/Display Make & Model: 27 inch
Re: Is it possible to batch add different text to mult photo
Or look somewhere else.
-
summersond
- Posts: 10
- Joined: Thu Jul 10, 2014 5:31 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- Hard_Drive_Capacity: 2tb
Re: Is it possible to batch add different text to mult photo
Thanks! That looks like it would work with some slight modifications to size, background color, etc. It doesn't import data from another source though which is what I was hoping for. Any ideas on that?
-
summersond
- Posts: 10
- Joined: Thu Jul 10, 2014 5:31 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- Hard_Drive_Capacity: 2tb
Re: Is it possible to batch add different text to mult photo
Radim, I saw your latest post after I posted. I will look into that now. Thanks much!
dave
dave
-
summersond
- Posts: 10
- Joined: Thu Jul 10, 2014 5:31 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- Hard_Drive_Capacity: 2tb
Re: Is it possible to batch add different text to mult photo
It looks like you need to insert some sort of loop to the external file until it hits an EOF msg, plus you would need it to recognize a delimiter to know what data to grab.
-
Radim
- Posts: 712
- Joined: Mon Nov 01, 2010 5:54 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- ram: 4GB
- Monitor/Display Make & Model: 27 inch
Re: Is it possible to batch add different text to mult photo
to loop: I am not sure -- PSP first load image and then apply script. You assume that script can load images in cycle? I do not see any function for that http://product.corel.com/help/PaintShop ... ndexL.html.
If your files were numbered like 001.jpg, 002.jpg etc. this number be used as index.
Or if you can edit some properties of images like EXIF of IPTC tags than you can use - http://www.highmotionsoftware.com/products/imbatch - you can contact author about specific request if needed he is open to new ideas
If your files were numbered like 001.jpg, 002.jpg etc. this number be used as index.
Or if you can edit some properties of images like EXIF of IPTC tags than you can use - http://www.highmotionsoftware.com/products/imbatch - you can contact author about specific request if needed he is open to new ideas
-
summersond
- Posts: 10
- Joined: Thu Jul 10, 2014 5:31 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- Hard_Drive_Capacity: 2tb
Re: Is it possible to batch add different text to mult photo
Yes, the files are numbered sequentially. Even if they weren't, they could easily be for the project.
-
Radim
- Posts: 712
- Joined: Mon Nov 01, 2010 5:54 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- ram: 4GB
- Monitor/Display Make & Model: 27 inch
Re: Is it possible to batch add different text to mult photo
Then there is no problem.
-
summersond
- Posts: 10
- Joined: Thu Jul 10, 2014 5:31 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- Hard_Drive_Capacity: 2tb
Re: Is it possible to batch add different text to mult photo
I did just send support question to ImBatch to see if their program does this.
Thanks!
Thanks!
-
Radim
- Posts: 712
- Joined: Mon Nov 01, 2010 5:54 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- ram: 4GB
- Monitor/Display Make & Model: 27 inch
Re: Is it possible to batch add different text to mult photo
So, finaly it is working.
Test images and script (ZIP archive) - http://leteckaposta.cz/756591511
Script put into your "Scripts-Trusted" folder.
You have to edit script (ProcessDirectorySimpleCaptionFromTextLine.PspScript):
1) on line 17 - set folder where are your images (named as 001.jpg, 002.jpg, etc.)
2) on line 18 - set path to text file with captions, each line is one caption (1st line for 001.jpg, 2nd line for 002.jpg, etc.)
3) between lines 47 and 133 is your (first record it and then copy here) styling of caption
4) edit your script to assign Caption (similar to line 105)
Test images and script (ZIP archive) - http://leteckaposta.cz/756591511
Script put into your "Scripts-Trusted" folder.
You have to edit script (ProcessDirectorySimpleCaptionFromTextLine.PspScript):
1) on line 17 - set folder where are your images (named as 001.jpg, 002.jpg, etc.)
2) on line 18 - set path to text file with captions, each line is one caption (1st line for 001.jpg, 2nd line for 002.jpg, etc.)
3) between lines 47 and 133 is your (first record it and then copy here) styling of caption
4) edit your script to assign Caption (similar to line 105)
Code: Select all
from PSPApp import *
import os.path
import fnmatch
import sys
import glob
# Template script to process files in a given directory tree. You can specify
# the tree to search, the files to open, and whether they should be saved or not.
# The ProcessFile method is called for each file opened, and then the file is
# optionally saved
#
# Areas you are expected to modify are marked with ***
# *** Set this to the directory tree you want to process
DirectoryToUse = r'C:\test\images'
FileWithCaptions = r'C:\test\textlines.txt'
# *** Include all of the extensions or patterns you care about - or just make it *.*
DirectorySearchString = [ '*.jpg', '*.PspImage', '*.png' ]
# *** Set this to true to search subdirectories of DirectoryToUse
# set it to false to search only in the specified directory
#SearchSubDirectories = False
SearchSubDirectories = False
# *** Set this value to true to save the file before closing it. If set to false the file
# is not saved, meaning that the ProcessFile method is responsible for doing something
# with the files
#SaveFileAfterProcessing = False
SaveFilesAfterProcessing = True
def ScriptProperties():
return {
'Author': u'Radim',
'Copyright': u'',
'Description': u'Open and process an entire directory of files.',
'Host': u'PaintShop Pro',
'Host Version': u'16.00'
}
def ProcessFile( Environment, FileName, Caption ):
' *** Process a single file - put your code here'
print 'Processing File %s' % FileName
# App.Do( Environment, 'Flip' )
# ***************** YOUR STYLING of CAPTION START HERE *******************
# Text
App.Do( Environment, 'TextEx', {
'Visibility': True,
'CreateAs': App.Constants.CreateAs.Vector,
'Start': (25,49),
'TextFlow': App.Constants.TextFlow.HorizontalDown,
'TextType': App.Constants.TextType.TextBase,
'Matrix': [
1,
0,
0,
0,
1,
0,
0,
0,
1
],
'AutoKern': True,
'Kerning': 0,
'Tracking': 0,
'Leading': 0,
'Font': u'Verdana',
'PointSize': 30,
'Italic': False,
'Bold': True,
'Underline': False,
'Strikethru': False,
'AntialiasStyle': App.Constants.AntialiasEx.Smooth,
'WarpText': True,
'SetText': App.Constants.Justify.Left,
'Fill': {
'Color': (254,59,28),
'Pattern': None,
'Gradient': None,
'Texture': None,
'Art': None
},
'Stroke': {
'Color': (253,254,20),
'Pattern': None,
'Gradient': None,
'Texture': None,
'Art': None
},
'LineWidth': 1,
'LineStyle': {
'Name': u'',
'FirstCap': (u'',0.25,0.25),
'LastCap': (u'',0.25,0.25),
'FirstSegCap': (u'',0.25,0.25),
'LastSegCap': (u'',0.25,0.25),
'UseSegmentCaps': False,
'Segments': None
},
'Join': App.Constants.JointStyle.Miter,
'MiterLimit': 10,
'Characters': Caption,
'Strings': None,
'TextTarget': (0,0,[1],True),
'PathTarget': None,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((16,0,0),1)
}
})
# Vector Align Horizontally in Center
App.Do( Environment, 'VectorAlignHorzCenter', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((16,0,0),1)
}
})
# Vector Align Bottom
App.Do( Environment, 'VectorAlignBottom', {
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((16,0,0),1)
}
})
# ***************** YOUR STYLING of CAPTION STOP HERE *******************
# LayerMergeAll
App.Do( Environment, 'LayerMergeAll', {
'WorkingMode': 0,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match,
'Version': ((16,0,0),1)
}
})
def SearchDir( OutList, CurrentDir, FilesInDir ):
''' Called by os.path.walk for each directory we encounter. Gets passed the
list of files we are building up (OutList), the directory we are visiting
(CurrentDir), and a list of all the filenames (without path) in the current
directory. We need to strip out anything that is a directory or doesn't
match our search string.
'''
for File in FilesInDir:
for SearchPattern in DirectorySearchString:
if fnmatch.fnmatch( File, SearchPattern ):
FullPath = os.path.join( CurrentDir, File )
# make sure what we have is a file and not a subdirectory
if not os.path.isdir( FullPath ):
OutList.append( FullPath )
def Do(Environment):
# do load Captions from text file; one line one caption
captions = []
inpFile = open( FileWithCaptions, "r" ) # path to your file
for line in inpFile:
captions.append( line.strip() ) # remove '\n' from end
inpFile.close()
print "1st caption is: ",captions[0] # only to see that we something loaded
# iterate through the search strings and glob all the results into one big list
CandidateFiles = [] # this will be a list of all the files we find
if SearchSubDirectories == True:
# walk the directory tree, calling SearchDir on each directory visited.
os.path.walk( DirectoryToUse, SearchDir, CandidateFiles )
else:
# just glob the path provided rather than walk a tree
for Search in DirectorySearchString:
# concatenate the dir and file spec together
SearchPath = os.path.join( DirectoryToUse, Search )
GlobbedFiles = glob.glob( SearchPath ) # glob will return a list of files
for File in GlobbedFiles: # now iterate the list
CandidateFiles.append( File ) # and add each one to candidate list
# going to have a problem if there aren't any files.
if len(CandidateFiles) == 0:
print >>sys.stderr, "No files found to process"
return
# now process the list of files
counter = 0
for File in CandidateFiles:
print 'Opening file ', File
# open the file
try:
App.Do( Environment, 'FileOpen', {
'FileList': [ File ],
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Silent,
'AutoActionMode': App.Constants.AutoActionMode.Match
}
})
# set the newly opened doc as the TargetDocument
App.Do( Environment, 'SelectDocument', {
'SelectedImage': 0,
'Strict': True,
'GeneralSettings': {
'ExecutionMode': App.Constants.ExecutionMode.Default,
'AutoActionMode': App.Constants.AutoActionMode.Match
}
})
except:
print >>sys.stderr, 'Error opening file %s - skipping' % File
# for simplicity, place your code in the ProcessFile method
ProcessFile( Environment, File, captions[counter] )
counter = counter + 1
# save the file
try:
if SaveFilesAfterProcessing == True:
App.Do( Environment, 'FileSave' )
# close the file before going on to the next
App.Do( Environment, 'FileClose' )
except:
print >>sys.stderr, 'Error on save/close of file %s - aborting' % File
Last edited by Radim on Fri Jul 11, 2014 4:16 pm, edited 1 time in total.
-
summersond
- Posts: 10
- Joined: Thu Jul 10, 2014 5:31 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- Hard_Drive_Capacity: 2tb
Re: Is it possible to batch add different text to mult photo
Thank you! I will try this out this weekend. Thanks for all of your help!
dave
dave
-
summersond
- Posts: 10
- Joined: Thu Jul 10, 2014 5:31 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- Hard_Drive_Capacity: 2tb
Re: Is it possible to batch add different text to mult photo
Quick question - What did you mean by this? edit your script to assign Caption (similar to line 105)
Not sure what I am supposed to insert here...
thanks!
Not sure what I am supposed to insert here...
thanks!
-
Radim
- Posts: 712
- Joined: Mon Nov 01, 2010 5:54 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- ram: 4GB
- Monitor/Display Make & Model: 27 inch
Re: Is it possible to batch add different text to mult photo
in your recorded style there will be your text so we need to replace it with variable named 'Caption' (which is 3rd parameter) in function
def ProcessFile( Environment, FileName, Caption )
def ProcessFile( Environment, FileName, Caption )
