How to manage a layer mask from a script and keys ?
Copy link to clipboard
Copied
Hello everybody !
For a long time I tried a foreign script that inserted a picture into a new layer with a mask (I found such examples on this site), then the mask was automatically made translucent and the user could transform the image at his discretion, the mask was unlinked. Then pressing Enter, the mask became normal and was linked to the layer.
I really can not understand the idea of how this was realized. Who has any thoughts and thoughts on this issue? Better the DOM, but but possible an ActionScript
Thanks !
Explore related tutorials & articles
Copy link to clipboard
Copied
Post that script...
Copy link to clipboard
Copied
I don't remeber where has it
Copy link to clipboard
Copied
What was that mask, some shape, opactity etc? Why that was needed, is that something you created to apply to your layers?
Copy link to clipboard
Copied
In my free photo collage toolkit the is and interactive Populate Collage script. The script highlight the area to be populated in the collage template. Then put you into an image file selection dialog where you select the image file you want to place into that area. Once you select the image file the script places the images into the template. Resize the image to fill the area and positions the image over the area and mask the smart object layer to that size and shape. The layer mask is unlinked and then the script puts you into an interactive transform command so you can adjust the smart object layers associated transform you can tweak the image composition add rotation and warp. Many time the will be no DOM support for what you want to script so you will need to use some action manager code in your scripts. Action manager code runs faster than DOM code.
http://www.mouseprints.net/old/dpr/InteractivePopulate.html
Photo Collage Toolkit
Photoshop scripting is powerful and I believe this package demonstrates this here is a video showing a 5 image collage PSD template being populated with images
The package includes four simple rules to follow when making Photo Collage Template PSD files so they will be compatible with my Photoshop scripts.
- Size the photo collage templates for the print size you want - width, height and print DPI resolution.
- Photo collage templates must have a Photoshop background layer. The contents of this layer can be anything.
- Photo collage templates must have alpha channels named "Image 1", "Image 2", ... "Image n".
- Photo collage templates layers above the background layers must provide transparent areas to let the images that will be placed below them show through.
There are fifteen scripts in this package they provide the following functions:
- HelpPhotoCollageToolkit.jsx - Online Help
- TestCollageTemplate.jsx - Used to test a Photo Collage Template while you are making it with Photoshop.
- CollageTemplateBuilder.jsx - Can build Templates compatible with this toolkit's scripts.
- LayerToAlphaChan.jsx - Used to convert a Prototype Image Layer stack into a template document.
- InteractivePopulateCollage.jsx - Used to interactively populate Any Photo Collage template. Offers most user control inserting pictures and text.
- ReplaceCollageImage.jsx - use to replace a populated collage image Smart Object layer with an other image correctly resized and positioned.
- ChangeTextSize.jsx - This script can be used to change Image stamps text size when the size used by the populating did not work well.
- PopulateCollageTemplate.jsx - Used to Automatically populate a Photo Collage template and leave the populated copy open in Photoshop.
- BatchOneImageCollage.jsx - Used to Automatically Batch Populate Collage templates that only have one image inserted. The Collage or Image may be stamped with text.
- BatchMultiImageCollage.jsx - Used to Automatically Batch Populate Any Photo Collage template with images in a source image folder. Easier to use than the interactive script. Saved collages can be tweaked.
- PasteImageRoll.jsx - Paste Images into a document to be print on roll paper.
- BatchPicturePackage.jsx - Used to Automatically Batch Populate Any Photo Collage template with an image in a source image folder. Images Rotates for best fit.
- BatchPicturePackageNoRotate.jsx - Used to Automatically Batch Populate Any Photo Collage template with an image in a source image folder.
- PopulatePicturePackage.jsx - Used to Automatically populate a Photo Collage template Fill with the same single image and leave the populated copy open in Photoshop.
- PCTpreferences.jsx - Edit This File to Customize Collage Populating scripts default setting and add your own Layer styles.
Copy link to clipboard
Copied
main()
function main()
{
try {
link_mask(false);
select_layer_rgb();
var den = app.activeDocument.activeLayer.layerMaskDensity;
app.activeDocument.activeLayer.layerMaskDensity = 50;
transform();
//menu("freeTransform");
app.activeDocument.activeLayer.layerMaskDensity = den;
link_mask(true);
}
catch(e) { alert(e); }
}
/////////////////////////////////////////////
function link_mask(state)
{
try {
var r = new ActionReference();
r.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ));
var d = new ActionDescriptor();
d.putReference( charIDToTypeID( "null" ), r );
var d2 = new ActionDescriptor();
d2.putBoolean( charIDToTypeID( "Usrs" ), state );
d.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Lyr " ), d2 );
executeAction( charIDToTypeID( "setd" ), d, DialogModes.NO );
}
catch(e) { throw(e); }
}
/////////////////////////////////////////////
function select_layer_rgb()
{
try {
var r = new ActionReference();
r.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( "RGB " ) );
var d = new ActionDescriptor();
d.putReference( charIDToTypeID( "null" ), r );
d.putBoolean( charIDToTypeID( "MkVs" ), false );
executeAction( charIDToTypeID( "slct" ), d, DialogModes.NO );
}
catch (e) { throw(e); }
}
/////////////////////////////////////////////
function menu(str)
{
try {
var r = new ActionReference();
r.putEnumerated( charIDToTypeID( "Mn " ), charIDToTypeID( "MnIt" ), stringIDToTypeID(str) );
var d = new ActionDescriptor();
d.putReference( charIDToTypeID( "null" ), r );
executeAction( charIDToTypeID( "slct" ), d, DialogModes.ALL );
}
catch (e) { beep() }
}
/////////////////////////////////////////////
function transform(linked)
{
try {
if (linked == undefined) linked = true;
var r = new ActionReference();
var d1 = new ActionDescriptor();
var d2 = new ActionDescriptor();
var ret = true;
try {
r.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
d2.putUnitDouble( charIDToTypeID( "Hrzn" ), charIDToTypeID( "#Rlt" ), 0 );
d2.putUnitDouble( charIDToTypeID( "Vrtc" ), charIDToTypeID( "#Rlt" ), 0 );
d1.putReference( charIDToTypeID( "null" ), r );
d1.putEnumerated( charIDToTypeID( "FTcs" ), charIDToTypeID( "QCSt" ), charIDToTypeID( "Qcsa" ) );
d1.putObject( charIDToTypeID( "Ofst" ), charIDToTypeID( "Ofst" ), d2 );
d1.putUnitDouble( charIDToTypeID( "Wdth" ), charIDToTypeID( "#Prc" ), 100 );
d1.putUnitDouble( charIDToTypeID( "Hght" ), charIDToTypeID( "#Prc" ), 100 );
d1.putBoolean( charIDToTypeID( "Lnkd" ), linked );
d1.putEnumerated( charIDToTypeID( "Intr" ), charIDToTypeID( "Intp" ), charIDToTypeID( "Bcbc" ) );
executeAction( charIDToTypeID( "Trnf" ), d1, DialogModes.ALL );
}
catch(e) { ret = false; }
return ret;
}
catch (e) { throw(e); }
}
Copy link to clipboard
Copied
Well done good work..
Copy link to clipboard
Copied
I agree with JJMack
a great job
AndreyLarush
Why do not you say it as an exact answer?

