Copy link to clipboard
Copied
Bonjour la commu !
Je suis en train de réfléchir à créer un outil avec photoshop pour mes prestations photo studio.
L'idée est de créer un droplet afin d'insérer les photo réalisées à la prise de vue, dans un template style "photobooth" et c'est là où ça se complique pour moi : Il faut que je puisse importer automatiquement le nom de la photo (nom du fichier donc) dans une zone texte et au bon endroit (qui reste statique à toutes les photos).
Y a t'il un moyen de faire cela où je fabule totalement ^^
Je vous ai mis une image de test pour vous montrer en gros ce dont j'ai besoin. Il faudrait remplacer les XXXXXX par le nom de la photo que je met dans le droplet.
Merci d'avance pour vos retours !
a plouch
Vladada
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var doc = app.activeDocument;
try {
doc.layers[0].textItem.contents = doc.layers[doc.layers.length-1].name
} catch (e) {};
};
I suspect that Vladada wants a slightly different result (only part of the text to be replaced), so I have changed your code slightly.
// as c.pfaffenbichler always said:
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var doc = app.activeDocument;
var _Search = /XXXXXXXX/g;
var _Replace = doc.layers[doc.layers.length-1].name;
try {
doc.layers[0].textItem.contents = doc.layers[0].textItem.contents.replace (_Search, _Replace);
} catch (e) {};
...
it's ok, I created a script with a shortcut and it's fast enougth.
So guys thanks a lot !
Copy link to clipboard
Copied
Could you please post screenshots the pertinent Panels (Toolbar, Layers, Options Bar, …) visible?
Copy link to clipboard
Copied
Yes I Can but I hyded some things cause it's not pertinent, I'll do what I need to do so I can modified all my settings
Copy link to clipboard
Copied
Is the Type Layer always the topmost Layer?
Is the Layer the name of which should be represented in the Type Layer always the lowermost Layer?
Copy link to clipboard
Copied
Yes it's always like that 🙂
Copy link to clipboard
Copied
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var doc = app.activeDocument;
try {
doc.layers[0].textItem.contents = doc.layers[doc.layers.length-1].name
} catch (e) {};
};
Copy link to clipboard
Copied
I suspect that Vladada wants a slightly different result (only part of the text to be replaced), so I have changed your code slightly.
// as c.pfaffenbichler always said:
// 2024, use it at your own risk;
if (app.documents.length > 0) {
var doc = app.activeDocument;
var _Search = /XXXXXXXX/g;
var _Replace = doc.layers[doc.layers.length-1].name;
try {
doc.layers[0].textItem.contents = doc.layers[0].textItem.contents.replace (_Search, _Replace);
} catch (e) {};
};
Assuming that you agree, I have used your image, the same text and the same layer structure for testing.
before
after
Copy link to clipboard
Copied
Ah, I hadn’t reread the original post after the last one by the op and misremembered the original point.
Copy link to clipboard
Copied
Hi there !
Thanks a lot you right! It's exactly what I need. I test this immediatly ! You rock guys
Copy link to clipboard
Copied
Problem, nothing's happens =/
I created a new project with the same things (folder, picture and layer) but the [filename] is not here
Copy link to clipboard
Copied
Could you please post screenshots with the pertinent Panels (Toolbar, Layers, Options Bar, …) visible or provide the file itself?
Copy link to clipboard
Copied
Does it work with the old project?
What has changed in the new project?
The script has no error management. Therefore, any deviation can cause the script to be cancelled.
A screenshot with visible open layer panel and visible title bar or a sample file.PSD would be helpful to check.
Copy link to clipboard
Copied
Hi guys,
Sorry for my late, but I tryed your script just with a new projet, with nothing inside and it doesn't work =/
I found that on internet :
// Insert FileName - Adobe Photoshop Script
// Description: creates text layer with current FileName as text. Option includes
// 1. include path to the current file
// 2. include file extension
// 3. size of font in pixel
// Requirements: Adobe Photoshop CS3, or higher
// Version: 0.0.1 - 06/Apr/2015
// Author: Anil Tejwani (anil@tejwani.com)
// Website: http://tejwani.com/
// ============================================================================
// Installation:
// 1. Place script in:
// PC(32): C:\Program Files (x86)\Adobe\Adobe Photoshop CS#\Presets\Scripts\
// PC(64): C:\Program Files\Adobe\Adobe Photoshop CS# (64 Bit)\Presets\Scripts\
// 2. Restart Photoshop
// 3. Choose File > Scripts > TS Insert FileName
// ============================================================================
// enable double-clicking from Mac Finder or Windows Explorer
#target photoshop
// bring application forward for double-click events
app.bringToFront();
if ( documents.length > 0 ){prefs = setPreferences(); main()}else{alert("ERROR!!!!!\nSeems we dont have any file open. \nNothing to do. 🙂 \nOpen a file and try again.")}
function setPreferences(){
var prefs = new Object();
/* EDIT STARTS HERE */
prefs.textFromBottom = 20;
prefs.startOffsetFromLeft = 20;
prefs.fontSize = '25px';
/* EDIT ENDS HERE */
prefs.incPath = true;prefs.incExt = true; prefs.originalDialogMode = app.displayDialogs;prefs.originalRulerUnits = preferences.rulerUnits; app.displayDialogs = DialogModes.ERROR; preferences.rulerUnits = Units.PIXELS;
return prefs;
}
function process(){var origDoc = activeDocument;var fullName = origDoc.name; if(!prefs.incExt){fullName = fullName.replace(/(?:\.[^.]*$|$)/, ''); }if(prefs.incPath){fullName = origDoc.path.toString() + " :: " + fullName;}var myLayerRef = origDoc.artLayers.add();myLayerRef.kind = LayerKind.TEXT;myLayerRef.name = fullName;var myTextRef = myLayerRef.textItem;myTextRef.position = new Array( prefs.startOffsetFromLeft, origDoc.height - prefs.textFromBottom );myTextRef.size = prefs.fontSize; myTextRef.contents = myLayerRef.name;}
function main(){try{setOptions();process();}catch( e ){/* An error occurred. Restore ruler units, then propagate the error back to the user */preferences.rulerUnits = prefs.originalRulerUnits;app.displayDialogs = prefs.originalDialogMode;throw e;}}
function setOptions(){
#target estoolkit
var win, windowResource;windowResource = "dialog { orientation: 'column', alignChildren: ['fill', 'top'], preferredSize:[350, 180], text: 'Photoshop Script - Insert FileName (TextLayer)', margins:10, settingPanel: Group { orientation: 'column',fontSize: Group { st4: StaticText { text: 'Select Font Size:' }, sl: Slider { minvalue: 10, maxvalue: 50, value: 25, size:[200,20] }, quality: StaticText { text: '25px', characters: 4} },incPath: Checkbox { text:'Include Path', value: true }, incExt: Checkbox { text:'Include Extension', value: true}, applyButton: Button { text: 'Insert»', properties:{name:'ok'},size:[350,30] , weight:bold }, dummy:StaticText { text: '' },alignChildren: 'left',} creditGroup: Group { orientation: 'row', alignChildren: 'right', linkText:StaticText { text: 'Visit us: www.tejwani.com/photoshop-scripting/' }, } }"
win = new Window(windowResource); /* listen and update text box */ win.settingPanel.fontSize.sl.onChange = function() {win.settingPanel.fontSize.quality.text = Math.round(this.value) + 'px';}
/* apply button */win.settingPanel.applyButton.onClick = function() {prefs.fontSize = win.settingPanel.fontSize.quality.text;prefs.incPath = win.settingPanel.incPath.value;prefs.incExt = win.settingPanel.incExt.value; return win.close();};
win.creditGroup.linkText.onClick = function() {File(app.path.toString() + "/Presets/Scripts/TS-insert-filename.html").execute();};win.show();
}
It's work !!!
So thanks a lot to you and see you 😄
Copy link to clipboard
Copied
Extremely interesting.
Because this script does something completely different to what you described at the beginning.
But it's great that it works for you.
Copy link to clipboard
Copied
yes, I don't understand scripts generaly but it works !
So when I solve a problem, an other come...
The problem is that the filename is the name of my .PSD and I would to create a layer with the filename of the picture that I put in my . PSD
I send you the psd and the screenshots to be more clear 😃
Thanks
Copy link to clipboard
Copied
The script you have found cannot do this without being changed. Please contact the creator for this.
And why do you want to insert the name of the file with a script and then replace the name with another one? (I'd rather not question the deeper meaning).
Two things were changed by you, and that's why my script doesn't work for it. But the script from @c.pfaffenbichler works with your example.PSD
Copy link to clipboard
Copied
The two ones doesn't work it's sad but I don't know why. Nothings happens.
For repky to your question, I'm photographer and I would to create a tool for my work in studio. I need to shoot people and print the picture just after, so I would to send the good picture at the good people by email and I need the good filename.
I find the way to print with droplet, I found the way to shoot and replace the picture but I don't know how can I do for the "good filename".
Copy link to clipboard
Copied
Please use the example file you last uploaded here: popauparc1.psd
Open this image in Photoshop only and then try the code snippet written here in this thread by @c.pfaffenbichler to get the wished result.
Copy link to clipboard
Copied
Please use the example file you last uploaded here: popauparc1.psd
Open this image in Photoshop only and then try the code snippet written here in this thread by @c.pfaffenbichler to get the wished result.
By @pixxxelschubser
YESSSSSS It works ! 😄 thanks a lot.
I just have to update all text layers, maybe there is something to automated this ?
Copy link to clipboard
Copied
it's ok, I created a script with a shortcut and it's fast enougth.
So guys thanks a lot !