Automate a process
Copy link to clipboard
Copied
So I'm trying to use Photoshop to add a number and a date in about 180 images, but I don't want to go through each one individually to add each line of text. I'm making a time lapse of myself and how I changed over 180 days (an example of this would be that I shaved my hair and I'm posting a video showing the regrowth of it over 180 days. Not what I actually did but it is similar, and you can find many videos like this on YouTube demonstrating what I'm trying to do), and I'd like to add the date for each photo I took, and what day it was in the process (i.e. day 1, day 2, day 37, day 180). I'm new to Photoshop, so I don't know much about the program, but I know there's a batch command somewhere; I wasn't able to find a tutorial anywhere on the specific thing I'm trying to do though. How could I add the specific day and date for each photo while not having to go through all of them individually?
Explore related tutorials & articles
Copy link to clipboard
Copied
There are scripts to add the filename and or time/date stamp to the image (or EXIF metadata etc). So if you were willing to batch rename the filename to be Day 1, Day 2 etc… And if you could pull the date/time metadata out of each file, then this should be possible. Try searching in the scripting sub-forum.
Otherwise, I would suggest that you look into Photoshop Variables. It should be “simple enough” to create a spreadsheet with a column for the Day 1 text and a column for the date. This could then be used to add text to each image.
Copy link to clipboard
Copied
Here I have used Adobe Bridge to batch rename a series of images. Each image was shot on a different day. I sorted the view by date created in Bridge. The critical point is that the sort order in Bridge is used as the input order for the batch rename command. The rename used a static text of “Day “ with a space, then it used an increment number padded with two zeros.
The filename would be picked up by a script, the script would also look for the date created metadata entry in the file as well. Both of these options would then be added as a text layer to the image.
Here is a rough sample of the output of a script (JJ Mack’s StampExif.jsx) where I removed all of the variables, except for filename and date. Further tweaks may be required, such as removing filename extension or changing date format, or the font size, colour etc. This is simply a proof of concept.
Copy link to clipboard
Copied
Thank you, but I'm still confused on the actions. I was able to rename all my files so now all i need to do is add the filename (and nothing else, i.e. no copyright marks, original dates, or camera lenses) to the photo. I saw stuff about this in one of your linked questions, how to add exif data, but there was so much information I didn't need, and I was somewhat confused by the process of doing it. How do I edit the script file so it only shows the file name without the file extension in the top corner or something like that? I saw JJMack answer a question similar to this but he didn't explain exactly how to edit specific parts of the text on the photo, he kind of just grouped it. The batch renaming the files was really helpful, all I need to do now is just add the file name of each photo to the actual photo, which is what I'm trying to figure out.
Copy link to clipboard
Copied
Filename only:
http://blogs.adobe.com/jkost/2010/09/add-file-name-as-text-layer.html
or
https://tejwani.com/photoshop-script-insert-current-filename/
Prepression: Downloading and Installing Adobe Scripts
I’ll post more later on the action and batch.
Copy link to clipboard
Copied
An action that used “insert menu command” to place the installed script into the scripts menu. I have added a few other steps to change the text (which could also be done in the script):
The File > Automate > Batch settings used to run the action on a folder of images (work on a test folder first that only contains a small amount of images to ensure that all works well):
EDIT: There appears to be a problem with my copy of the “AddFileName20pt” script, however the process should be the same/similar for similar scripts.
Copy link to clipboard
Copied
In the "Set:" setting I don't have the option for filename to layer, where did that come from? And what would I be batch automating anyways (such as what file I would open to do this)? Also I don't see that little menu-like thing in the first photo anywhere.
Copy link to clipboard
Copied
Have you made actions before? Have you used the Batch command before to run an action over a folder containing multiple files?
Filename to Layer is simply what I called my action set, rather than the default Set 11 etc. Same for the action Run rather than Action 11 etc.
P.S. The AddFileName20pt.jsx should be fine, the error was in my action (I used set current text layer when I should have used set text style of current layer).
Copy link to clipboard
Copied
This is my second day of using photoshop and I haven't gotten around to really watching anything about it so so far I've only ever done anything you've said, and I doubt I've done it correctly. The addfilename20 worked, and it did add the file, but it was very small and it was in the middle of the photo. Is there anyway I can set it to put the text in a different color, place, and size? The other thing from earlier that was similar to that from tejwani was closer to what I was looking for, but the max text size wasn't high enough for me and couldn't change the colors. And no, I don't know what actions really are, but from the name I have a decent guess; not sure how to execute them properly though.
Copy link to clipboard
Copied
This is my second day of using photoshop
Ah, OK, I was presuming a much greater level of knowledge and experience!
Actions and the Actions panel in Photoshop
Create actions in Adobe Photoshop
The addfilename20 worked, and it did add the file, but it was very small and it was in the middle of the photo. Is there anyway I can set it to put the text in a different color, place, and size?
You can either change the script code (rough example image below):
Or record the steps to change the result of the script code using an action – which is what my screenshot demonstrated (although there was an error which I have fixed below):
However what might be easier is for you to list exactly what font, size, colour, position etc… Then I can provide you an action or possibly script code that does what you wish.
Copy link to clipboard
Copied
Yea I have almost no idea what I'm doing so I'll just tell you; thank you for being so helpful - best person I've ever seen on forums. So I'd like my text to be in the top left corner (No extremely specific spot, just out of the way), and I'd like it to be at 85px and in white. The basic font or whatever you use is fine - as long as its bold and easily read. Again, thanks for all your help.
Copy link to clipboard
Copied
What width and height are your images in pixels? What resolution are your images? 72 ppi or something else?
You can use the image > image size command to find out the dimensions in px and the resoluiton in pixels per inch (PPI).
And you want 85 px and not 85 pt for the font size height?
I have a modified script all ready to go once these details are confirmed!
Copy link to clipboard
Copied
Run script, choose folder containing .jpg files. When process is done you find in the same folder a 'Fld' folder with new files:
displayDialogs = DialogModes.NO
preferences.rulerUnits = Units.PIXELS
f = Folder.selectDialog().getFiles(r = /\.jpg$/i);
if (l = f.length) Folder(p = f[0].parent + '/Fld').create()
for(i = 0; i < l;) {
open(f[i++]); with(activeDocument) {
artLayers.add().kind = LayerKind.TEXT
s = height / 100 * 5 * 72 / resolution, n = name,
(tI = activeLayer.textItem).contents = n.split(r)[0]
tI.position = [85, 170], color = new SolidColor;
(j = new JPEGSaveOptions()).quality = 12
color.rgb.hexValue = 'FFFFFF'
tI.color = color, tI.size = s
saveAs(File(p + '/' + n), j)
dn = 'DONOTSAVECHANGES'
s = 'SaveOptions.' + dn
close(eval(s))
}
}
Copy link to clipboard
Copied
Sweet, no need for IP, IPP or Batch!
Copy link to clipboard
Copied
Sorry for not responding, I've been having trouble with other things, and I thought I had previously responded but I guess I hadn't hit send. Ok I tried this script and for 8/10 of the photos it worked great, but for some others the date wasn't in the corner, it was more towards the middle of the photo, in most cases resting on my hair or right above my forehead. Not sure why it happened, but its a problem. A lot of my photos aren't centered correctly; could that be it (and I don't know how to fix this either)? And on a different note, is there any way to change it to an American time format (MM/DD/YYYY rather than DD/MM/YYYY), as I am from America and most of my viewers will be from America. If not it's not a big problem I just don't know how to do it myself.
EDIT: A couple of days ago I switched out some of the photos because they were blurry. I was able to upload clearer ones from my phone, but all the photos I fixed now show the wrong date, and are the ones where the date position is messed up.
Copy link to clipboard
Copied
What script, where did you get it? Each reply in this forum has a little grey number in the upper left, for example I am replying to your post #23.
My original post was an edit of JJ Mack’s script, where I removed all variables from the output except filename and date created.
Then we moved on to other scripts that only used the date, or only used the filename – not both… Or so I thought.
Before we can look at changing the date format to U.S., the forum needs to know where it is coming from and how it is being used in the script. For example, if the script was the one posted by Kukurykus in reply #12, then the following change to the original line 4 code would put the month first, then the day:
function(_, v1, v2, v3, v4) {return v2 + '.' + v3 + '.' + v1})
As for the text position, my previous action posts show how to use a select all/align text to absolute upper left, move across/down fixed number of pixels and deselect to ensure that all text is consistent in placement (i.e. reply #9). Apparently this is harder to do in a script (unless my research has lead me to the wrong conclusion). I have very verbose script code to do this, but I’m sure that others can do it a lot cleaner.
Copy link to clipboard
Copied
My bad, I didn't see the numbers. I was talking about Kukurykus' most recent reply, 21. If you ever have a question about what code I'm referencing and I didn't specify, just assume its the latest code. I saw your reply about moving all the text, but these files are completed already and have the (wrong) date on them already. I'd have to open close to 30 of them in Photoshop and manually edit them, something that would likely take my laptop a long time to do. I guess if there's no solution in the scripts to fix it I can try it, but it would be very tedious and annoying, and probably take a couple of hours; something I'd like to avoid.
Copy link to clipboard
Copied
If the files have an editable text layer, a batch action or script can delete the text layer on the incorrect images.
Or just trash the images and reprocess the originals with a script that uses the date format that you require.
I’m still confused how you have put the renamed file name and the date created into a text layer, when the scripts posted only do one or the other, not both.
Copy link to clipboard
Copied
"I’m still confused how you have put the renamed file name and the date created into a text layer, when the scripts posted only do one or the other, not both." The filename was the date, plus an extra numbering number, so I'm assuming the filename is what was used, which is also the date.
As for the other part, I don't know how to change the date format; I don't see your line of code (24) in Kukurykus' lines of code (21). I'll most likely ditch all the files and add a new text layer to all the old ones but even if the date is changed to my format I suspect those same files which had the text position messed up will continue to have that problem.
Copy link to clipboard
Copied
The filename was the date, plus an extra numbering number, so I'm assuming the filename is what was used, which is also the date.
Ah, as you did not explicitly state what you originally did, I assumed that you renamed your files as “Day 001” etc.
As for the other part, I don't know how to change the date format; I don't see your line of code (24) in Kukurykus' lines of code (21). I'll most likely ditch all the files and add a new text layer to all the old ones but even if the date is changed to my format I suspect those same files which had the text position messed up will continue to have that problem.
The line of code that I changed was post #12. We have moved on since then! You now have me totally confused.
We can rename the filename of the source files to have the MMDDYYYY order using either a metadata or regular expression based string replacement in Adobe Bridge. Or script code could be used to get to the same result.
As for consistent text positioning, are all your images the same width/height in pixels? What PPI are your files?
It is easy to reposition the text layer on multiple files to a consistent location using an action, perhaps less easy using a script (for me, perhaps not others).
It would be helpful if you could copy and paste an example of two of your filenames, and perhaps a sample image crop showing the result of the text on the image.
Copy link to clipboard
Copied
My bad, some of the images are 1932 x 2576 while others are 750 x 1000. I'll try to find a fix and come back to this if it works.
Copy link to clipboard
Copied
And the PPI value (see my post #11), the script code is noted to be programmed for 300ppi input.
Copy link to clipboard
Copied
The dpi is 72, so I assume the ppi is also 72.
Copy link to clipboard
Copied
There is no DPI, it is only PPI in this case.
Edit: I tested the same size file at both 300ppi and 72ppi and the text was in the same position. So this may have less to do with the end result than I thought.
Copy link to clipboard
Copied
I wrote a script that put on image (but in down right corner) a date writen to metadata. It's also not on white background: Re: Way to have the "create just date " to print into photo? / Here is also rewriten version for your specific expectation:
displayDialogs = DialogModes.NO, preferences.rulerUnits = Units.PIXELS;
(aD = activeDocument).artLayers.add().kind = LayerKind.TEXT
d = aD.info.creationDate.replace(/(\d{4})(\d{2})(\d{2})/,
function(_, v1, v2, v3, v4) {return v3 + '.' + v2 + '.' + v1})
s = aD.height / 100 * 5 * 72 / aD.resolution;
(tI = aD.activeLayer.textItem).contents = d
tI.position = [85, 170], col = new SolidColor
col.rgb.hexValue = 'FFFFFF'
tI.color = col, tI.size = s
Try it on single layer if you know how to use this script, then it can be automated for all 180 layers. Also post your video


-
- 1
- 2