What's new

Actions Filename inside image


Miketea

New Member
Messages
4
Likes
0
Hey all,

I have been tasked with adding the filename of hundreds of TIFF’s into the image on a separate text layer.

The text needs to be 8pt Arial and sit at the very bottom right of the image.

Any ideas how this can be done. An action turned to a droplet would be really handy.

I’m more of and InDesign guy but these images need to stay as TIFFs for future edits.

Thanks
 

Dormeur74

Well-Known Member
Messages
47
Likes
38
A script is not very difficult to write but some details are important :
- width in pixels of the margins from the right and bottom edges?
- color of the police if the backkground is 1) dark 2) light?
- and which Arial font : there are 9 different fonts.
 

Paul MR

The Script Master
Messages
369
Likes
202
Here is an example that will do a folder of tif's
Code:
#target photoshop;
app.bringToFront();
main();

function main(){
//// AMEND TO SUIT///////////////////////////////////////////////////////////////////////////
var fontSize = 8;  // Font Size
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
inputFolder = Folder.selectDialog("Please select the folder with Files to process");
if(inputFolder == null) return;
var fileList = inputFolder.getFiles(/\.(tif)$/i);
app.displayDialogs = DialogModes.NO;              
var strtRulerUnits = app.preferences.rulerUnits;                
var strtTypeUnits = app.preferences.typeUnits;                
app.preferences.rulerUnits = Units.PIXELS;                
app.preferences.typeUnits = TypeUnits.PIXELS; 
for(var a =0 ; a<fileList.length;a++){
    var file = fileList[a];
    open(file);
doc = app.activeDocument;
var res =doc.resolution;
if (res.resolution != 72){doc.resizeImage(undefined, undefined, 72, ResampleMethod.NONE);}
var fontName = "ArialMT"; 
var textColor = new SolidColor(); 
textColor.rgb.hexValue = '000000';     
var newTextLayer = doc.artLayers.add();
newTextLayer.name="Filename";
newTextLayer.kind = LayerKind.TEXT; 
newTextLayer.textItem.kind = TextType.POINTTEXT;
newTextLayer.textItem.color = textColor; 
newTextLayer.textItem.font = fontName;
newTextLayer.textItem.size = fontSize; 
newTextLayer.textItem.contents = app.activeDocument.name.replace(/\.[^\.]+$/, '');
align("AdBt");
align("AdRg");
doc.resizeImage(undefined, undefined, res, ResampleMethod.NONE);
app.activeDocument.close(SaveOptions.SAVECHANGES); 
}
preferences.rulerUnits = strtRulerUnits;
function align(method) { 
activeDocument.selection.selectAll();
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) ); 
desc.putReference( charIDToTypeID( "null" ), ref ); 
desc.putEnumerated( charIDToTypeID( "Usng" ), charIDToTypeID( "ADSt" ), charIDToTypeID( method ) );
try{
executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO ); 
}catch(e){}
activeDocument.selection.deselect();
};
};
 

Miketea

New Member
Messages
4
Likes
0
Sorry the replies went into my junk.

1. There doesn't need to be a margin. The text could be right aligned at 0px to the bottom right hand corner (its just a reference code).
2. Any Arial typeface is fine, just so its legible.
3. I don't need to worry about a 'save and close' feature. I can review and save myself.
4. Text can always be black also.

I'm new to scripts so this is my first challenge. Could I copy and paste Pauls code and edit myself?

Thanks
 

Dormeur74

Well-Known Member
Messages
47
Likes
38
I think that Paul wrote this excellent script for you.

You have just to add the following line :
app.preferences.typeUnits = strtTypeUnits;

after :
preferences.rulerUnits = strtRulerUnits;
 

Top