Copy link to clipboard
Copied
When I import a file into photoshop, can I have the "background" layer show the PSD file name?
Yes it works. The basic script is installed by default with Photoshop. More on Script Events Manager here:
https://prepression.blogspot.com/2021/10/photoshop-script-events-manager.html
EDIT: Recently discussed in this recent topic thread -
Copy link to clipboard
Copied
You don't import a file, you just open it. And a background layer can't have a different name or it won't be a background layer. I suppose you could add an empty layer to every file with the filename, but why?
Copy link to clipboard
Copied
When I'm compositing, I'd like the background layer to show the original filename similiar to when you load files into a stack.
Copy link to clipboard
Copied
You can convert a background layer to a normal layer and name it anyway you want. All PSD do not have a background layer. The background layer is special bottom layer and one is not required. You can script the process even make an open event handler. But you need to handle what you want to do when there is no background layer. You will be making all PSD to not have as background layer you will most likely open these also and If you save the PSD with a new file name will you also be renaming the bottom layer. Save even handlers are triggered after the save completes the rename can not be done by a save even handler the documen may not longer be in Photoshop. The open event handler can rename a bottom normal layer. The open event handler would need to be a script so it can use logic to determine what kind of layer the bottom layer is in a PSD file and be able to retrieve the backing file name and file type,
Copy link to clipboard
Copied
I think this is what I'm looking for
Does anyone know if this works for 23.1.0?
Copy link to clipboard
Copied
Yes it works. The basic script is installed by default with Photoshop. More on Script Events Manager here:
https://prepression.blogspot.com/2021/10/photoshop-script-events-manager.html
EDIT: Recently discussed in this recent topic thread -
Copy link to clipboard
Copied
That was perfect! Thanks! Is it possible to add "lock layer" step to the end of that script?
Copy link to clipboard
Copied
@ipv1 wrote:
That was perfect! Thanks! Is it possible to add "lock layer" step to the end of that script?
Sure, here is a function with the various parameters to swap in/out:
lockLayer("protectAll");
function lockLayer(protectStringValue) {
// "protectTransparency"
// "protectComposite"
// "protectPosition"
// "protectArtboardAutonest"
// "protectAll"
var idapplyLocking = stringIDToTypeID("applyLocking");
var desc549 = new ActionDescriptor();
var idnull = stringIDToTypeID("null");
var ref127 = new ActionReference();
var idlayer = stringIDToTypeID("layer");
var idordinal = stringIDToTypeID("ordinal");
var idtargetEnum = stringIDToTypeID("targetEnum");
ref127.putEnumerated(idlayer, idordinal, idtargetEnum);
desc549.putReference(idnull, ref127);
var idlayerLocking = stringIDToTypeID("layerLocking");
var desc550 = new ActionDescriptor();
var idprotectTransparency = stringIDToTypeID(protectStringValue);
desc550.putBoolean(idprotectTransparency, true);
var idlayerLocking = stringIDToTypeID("layerLocking");
desc549.putObject(idlayerLocking, idlayerLocking, desc550);
executeAction(idapplyLocking, desc549, DialogModes.NO);
}
Copy link to clipboard
Copied
Awesome! This makes me want to go down further into the scripts rabbit hole. Appreciate your help on this. Cheers
Copy link to clipboard
Copied
Okay, I have one more request. Can I add layer mask to that background layer before locking it? Thank you thank thank you!
Copy link to clipboard
Copied
Yes, I'll post the code tomorrow, bed calls!
Do you need a white or black mask? Is this based off a selection or just the entire layer?
Copy link to clipboard
Copied
just a white mask, entire layer. thanks so much!
Copy link to clipboard
Copied
Do you want a regular layer of a background layer? A background layer can't have a mask.
Copy link to clipboard
Copied
Here you go:
addMask("revealAll");
function addMask(maskVisibility) {
// maskVisibility = "revealAll" or "hideAll"
if (!app.activeDocument.activeLayer.isBackgroundLayer) {
var c2t = function (s) {
return app.charIDToTypeID(s);
};
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
descriptor.putClass(s2t("new"), s2t("channel"));
reference.putEnumerated(s2t("channel"), s2t("channel"), s2t("mask"));
descriptor.putReference(s2t("at"), reference);
descriptor.putEnumerated(s2t("using"), c2t("UsrM"), s2t(maskVisibility));
executeAction(s2t("make"), descriptor, DialogModes.NO);
}
else {
//alert("The active layer is a Background layer!");
}
}
Copy link to clipboard
Copied
You're the best! Appreciate all your help - happy holidays sir
Copy link to clipboard
Copied
Just in case somebody is looking for "standard code":
app.activeDocument.activeLayer.allLocked = true;
app.activeDocument.activeLayer.pixelsLocked = true;
app.activeDocument.activeLayer.positionLocked = true;
app.activeDocument.activeLayer.transparentPixelsLocked = true;
Copy link to clipboard
Copied
A conditional action can check for the Background layer and promote it to a standard layer, it just can't name it after the open document name, a script is required for that. This is one of the "rare" cases where the conditional actions are useful:
Find more inspiration, events, and resources on the new Adobe Community
Explore Now