Skip to main content
Participating Frequently
August 13, 2025
Answered

Image number with the photo

  • August 13, 2025
  • 3 replies
  • 348 views

I want to print order forms for my clients, the image with the image number must be on the form.

I can write the script for the placing of the image, but how do I include the image name/number. I have seen it done in Photoshop but I do not know how to include the file name

Can som one help please

[Personal email removed by moderator]

Correct answer M-H

To place a image you need to provide path for it and you can get the name from the path, for example:

var placedImagePath = File("/d/images/image_no_0001.jpg")
var placedImageName = placedImagePath.name

placeImageFromPath(placedImagePath);

var textLayer = activeDocument.artLayers.add();
textLayer.kind = LayerKind.TEXT;
textLayer.textItem.contents = placedImageName;

function placeImageFromPath(path) {
    cTID = function(s) { return app.charIDToTypeID(s); };
    sTID = function(s) { return app.stringIDToTypeID(s); };
    var desc1 = new ActionDescriptor();
    desc1.putPath(cTID('null'), path);
    desc1.putEnumerated(cTID('FTcs'), cTID('QCSt'), sTID("QCSAverage"));
    var desc2 = new ActionDescriptor();
    desc2.putUnitDouble(cTID('Hrzn'), cTID('#Prc'), 0);
    desc2.putUnitDouble(cTID('Vrtc'), cTID('#Prc'), 0);
    desc1.putObject(cTID('Ofst'), cTID('Ofst'), desc2);
    var desc3 = new ActionDescriptor();
    var ref1 = new ActionReference();
    desc1.putObject(sTID("replaceLayer"), cTID('Plc '), desc3);
    executeAction(cTID('Plc '), desc1, DialogModes.NO);
}

3 replies

M-HCorrect answer
Inspiring
August 13, 2025

To place a image you need to provide path for it and you can get the name from the path, for example:

var placedImagePath = File("/d/images/image_no_0001.jpg")
var placedImageName = placedImagePath.name

placeImageFromPath(placedImagePath);

var textLayer = activeDocument.artLayers.add();
textLayer.kind = LayerKind.TEXT;
textLayer.textItem.contents = placedImageName;

function placeImageFromPath(path) {
    cTID = function(s) { return app.charIDToTypeID(s); };
    sTID = function(s) { return app.stringIDToTypeID(s); };
    var desc1 = new ActionDescriptor();
    desc1.putPath(cTID('null'), path);
    desc1.putEnumerated(cTID('FTcs'), cTID('QCSt'), sTID("QCSAverage"));
    var desc2 = new ActionDescriptor();
    desc2.putUnitDouble(cTID('Hrzn'), cTID('#Prc'), 0);
    desc2.putUnitDouble(cTID('Vrtc'), cTID('#Prc'), 0);
    desc1.putObject(cTID('Ofst'), cTID('Ofst'), desc2);
    var desc3 = new ActionDescriptor();
    var ref1 = new ActionReference();
    desc1.putObject(sTID("replaceLayer"), cTID('Plc '), desc3);
    executeAction(cTID('Plc '), desc1, DialogModes.NO);
}
Stephen Marsh
Community Expert
Community Expert
August 13, 2025

@M-H 

 

That's a better example, my one was presuming that the image was the active document.

Stephen Marsh
Community Expert
Community Expert
August 13, 2025

@Louis F Taljaard 

 

Presuming legacy ExtendScript, to set the variable.

 

Filename, including extension:

var docName = app.activeDocument.name;

 

Filename, sans extension:

var docName = app.activeDocument.name.replace(/\.[^\.]+$/, '')

 

 Then you need to create the text referencing the variable as the .content

 

(example to come)

creative explorer
Community Expert
Community Expert
August 13, 2025

@Louis F Taljaard are you talking about a "contact sheet" style layout, Photoshop also has a built-in feature under File > Automate > Contact Sheet II. This tool can automatically arrange multiple images on a page and include their filenames as captions. While this might not give you a traditional "order form" layout, it's a quick way to get a single document with all your images and their names. 

m
Participating Frequently
August 21, 2025

No, I need to print order forms with the image and image number on it. It's between a 1 000 and 2 000 forms I have print.

I use to prin the contact sheet and the gluede it on the order form

I'm must do somthing to save time