• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

script to detect two layers define clipping mask

Explorer ,
Feb 06, 2020 Feb 06, 2020

Copy link to clipboard

Copied

Hello all scripters,

Two layers define a clipping mask:

Photoshop-LinkedLayers.PNG

This is a rectangular dynamic form and a High Res smart Object.

 

Now, in a script, I have to detect that these two layers form the clipping mask.

By now, I see no property that I could use: Document.layerSets and Document.layerComps are empty, and Layers' properties don't indicate these two layers are related.

Any Idea?

TOPICS
Actions and scripting

Views

2.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

People's Champ , Feb 06, 2020 Feb 06, 2020
For the first layer, the property "grouped" == true

Analyze layers down on the stack.
When you find a layer with "grouped" == false, you will get a second layer.
 

Votes

Translate

Translate
Adobe
People's Champ ,
Feb 06, 2020 Feb 06, 2020

Copy link to clipboard

Copied

For the first layer, the property "grouped" == true

Analyze layers down on the stack.
When you find a layer with "grouped" == false, you will get a second layer.
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Feb 07, 2020 Feb 07, 2020

Copy link to clipboard

Copied

Thank you, I didn't see in the JS CC Ref 2019 guide that this property 'grouped' is related to a clipping mask 🙂

Is this property related to other grouping technique or just the clipping mask?

Thank you, this will help me to automate a complex workflow with resizing.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Feb 07, 2020 Feb 07, 2020

Copy link to clipboard

Copied

Previously, when there were no folder-groups in Photoshop, the clipping layers were called grouped. The name of the property was left unchanged.
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 15, 2021 Sep 15, 2021

Copy link to clipboard

Copied

Can you please provide an example selects the two layers, groups them, and the applies the clipping mask to the top layer.

 

Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 18, 2021 Sep 18, 2021

Copy link to clipboard

Copied

I figured it out...   Here is a Python snippet I used to create a collage that would grab images from a folder and import them into one document on a new layer. In between each layer I created a new layer with a black square box that I want to clip the image into. The createPlaceHoderBlock() method simply produces a new layer and places a square block in docRef

 

width=12
height=8
docRef = app.Documents.Add(width, height, 300)
image_files = glob.glob(source_path + '/' + '*.jpg')
for fileName in image_files:
   createPlaceHolderBlock()
   srcdoc=app.Open(fileName)
   srcdoc.resizeImage(newWidth,newHeight,Resolution)
   srcdoc.Close() # close new image
   NewLayerRef = srcdoc.ArtLayers[0].Duplicate(docRef) # copy new image into docRef
   NewLayerRef.translate(newx_inches,newy_inches) # This will translate to placeholder location
# All that is needed to apply the clipping mask to the layer below is the use 
NewLayerRef.grouped=True.
   NewLayerRef.grouped=True

 

Here's a screenshot:

Screenshot 2021-09-18 103137.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 18, 2021 Sep 18, 2021

Copy link to clipboard

Copied

I created a simple Collage template for placing in Images. Because there are no smart Object Images layers in the templates.  Placed in images can not be rotated and Warped by existing placed in image smart objects layer image place holders by the smart object layer's object transform.   For a collage template all the use required is a Photoshop Background layer in the template and Image  Alpha channel to map up the 53 Images ins a collage.  These Alpha channels map  the images Location, Size and Shape.  Image are  placed in  in file name sort order.  Image 1 is placed in above  the Background layer and scaled to fill the bounds of Image 1 Alpha channel selection and positioned centered to the bounds the masked  to the Selections shape.  This is repeated for the other images. each is placed in above the previous place in image.  The Script can add Text File name stamps over the Image location.  These stamp are added as the top layer  above all other later in the document when each image has been placed in sized positioned and mask.  The collage scripts can also are Layer styles the Placed in images and text stamps.  I wanted Collage templates to be easy to create and populate.

 

Free Photoshop Photo Collage and Mockup Toolkit 

 

Capture.jpg

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 26, 2023 Jul 26, 2023

Copy link to clipboard

Copied

Hi sir, I have recently started working on the same project but I don't know JavaScript I know the python I have used 

Win32com.client for some automation but I am not able to insert images in the layer which I want. If you provide your code it will be helpful for me

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 26, 2023 Jul 26, 2023

Copy link to clipboard

Copied

LATEST
quote

Hi sir, I have recently started working on the same project but I don't know JavaScript I know the python I have used 

Win32com.client for some automation but I am not able to insert images in the layer which I want. If you provide your code it will be helpful for me


By @vilas_4

 

Sadly, JJMack is no longer with us.

 

You can find his scripts here:

 

https://github.com/MarshySwamp/JJMack-Archive

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 26, 2023 Jul 26, 2023

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines