What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Scripting Way to have the "create just date " to print into photo?


idjev

Member
Messages
10
Likes
0
I'm trying to automate the process of adding the date from a photos metadata to a photo so that it's visible on the photos bottom right hand corner when viewed/printed?

Way to have the "create just date " to print into photo?
Metadata > Date Created
bottom right corner write (sample : 31.01.2018)
Thank you...
 

Attachments

  • 20180203172413qdb.jpg
    20180203172413qdb.jpg
    133.2 KB · Views: 4
  • 2018-02-03_172413.jpg
    2018-02-03_172413.jpg
    133.2 KB · Views: 3
Last edited:
Code:
#target photoshop;
if(documents.length){
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
var xmp = new XMPMeta(activeDocument.xmpMetadata.rawData); 
if( xmp.doesPropertyExist(XMPConst.NS_XMP, "CreateDate" ) ) {
var date = new Date(new XMPDateTime(xmp.getProperty( XMPConst.NS_XMP, "CreateDate" ).toString()).getDate().getTime());
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var dom = date.getDate();
var dayM = (dom < 10) ? '0' + dom : dom;
var year = (yy < 1000) ? yy + 1900 : yy;
var FontName = "Arial"; 
var FontSize = 16;
var black = new SolidColor(); 
black.rgb.hexValue = '000000'; 
newTextLayer = activeDocument.artLayers.add(); 
newTextLayer.kind = LayerKind.TEXT; 
newTextLayer.textItem.kind = TextType.POINTTEXT
newTextLayer.textItem.color = black; 
newTextLayer.textItem.font = FontName;
newTextLayer.textItem.size = FontSize; 
newTextLayer.textItem.contents=dayM+"."+month+"."+year;
activeDocument.selection.selectAll();
align('AdRg');
align('AdBt');
activeDocument.selection.deselect();
activeDocument.activeLayer.translate (-10, -10);
}else{
    alert("sorry this document does not have the create date!");
    }
}
function align(method) { 
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 ) );
executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO ); 
};
 

Back
Top