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

Photoshop Scripting for Clipping Path/Mask

New Here ,
Mar 30, 2018 Mar 30, 2018

Copy link to clipboard

Copied

I am new to Photoshop scripting. I am trying to edit a batch of images by doing the following:

1. white background layer

2. add 1st image layer

3. add 2nd image layer

4. apply clipping path/mask to 2nd image layer

5. open the file through photoshop to continue editing or save file as a psd

Is it possible to create a script doing the following above? If so, what scripting codes should I use to do so?

Thank you!

TOPICS
Actions and scripting

Views

4.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
Adobe
New Here ,
Mar 30, 2018 Mar 30, 2018

Copy link to clipboard

Copied

Adding on to my question. If I am not able to apply the clipping path. I would like to do the following within the script:

1. white background layer

2. add 1st image layer (same image every run)

3. add 2nd image layer (different image every run)

4. open file to apply clipping path manually

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 ,
Apr 01, 2018 Apr 01, 2018

Copy link to clipboard

Copied

Forget that you using Photoshop.  Describe what you want to do.   Do not write in term of editing digital images.    Lets just say your have a pile prints and you want to make a set of montages.  Describe your mortgages.

To me what you seam to want to do is just simply add a second images to  constant first image.   That should be very easy to do with Photoshop if all  the second image are the same size and have the same Aspect ration and resolution. And you want  the second image the be in same location relative to the first constant image.    A relatively easy to record action should be able to able to be used to Batch process all your images.  All you second images should be in a folder to be batch process with the action you record.   Photoshop batch Process would open one image at time your action would add canvas to the opened  image to house the First constant image.  The Action would then place that  image into the added canvas area and the save out populated montage.  This processes will be repeated for all the other images being patched processed.. You will only need to add a Layer mask if you need to logically crop your images to a different aspect ration then they have.   To create the montage you want to.  You need to design what you montage composition will be.

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 ,
Apr 04, 2018 Apr 04, 2018

Copy link to clipboard

Copied

Hi whitneyw62210287

What you are doing is fairly straightforward however you need to be slightly more specific with your requirements. Do your existing batch of files already have the paths on them? Could you maybe either send me an example file or two of the files that you want to process?

I can certainly put together a script for you that will do this job quite efficiently.

Also I should point out that if you would like to learn how to do this for yourself, have a look at www.photoshopscripting.com.au, the discount code LRNJS4PS is still active at 25 percent off. Those lessons will step you through all of the concepts you need to be able to make something like this.

I will write something up for you tomorrow and get back to you.

Thanks

James

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 ,
Apr 05, 2018 Apr 05, 2018

Copy link to clipboard

Copied

My existing batch of files does not have the paths on them. What I am doing basically is replacing the background of a image. Once I bring the batch of files ( MAIN IMAGE) into photoshop, I add another layer that contains the background image that I am using to replace (BACKGROUND IMAGE). (The background image is the same image for the existing batch of files. In order for me to replace the background of the main image with the background image, I use the magic wand selection tool in all four corners of the main image layer. When refining the edge, smooth is set to 30. The next step is to invert the selection and create a layer mask to the main image layer. I would like the script to leave the file open in photoshop so that I may edit and do any cleaning to it.

Do you have a script to where I can just plug in information.

Hopefully all of this makes sense, I am new to the scripting so I will definitely check out the website.

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 Expert ,
Apr 05, 2018 Apr 05, 2018

Copy link to clipboard

Copied

My First append I described an Action you could record to do what you want to batch. Which is to add the same background to a batch of imaged.    I also posted  a description of my Photo Collage Toolkit which will enable you to populate  more complex composite PSD files. If you read the documentation you well see it is very easy to create templates there are only four simple rules.  Image are populated in image number ordered stacked above the required background layer size, positioned and mask to shape.  If Image 1 mapping alpha channel is Canvas Size.  Image 1 would cover all of the Background layers and the other images would be populated in the positions above  image 1.  You can also control the sequences image files well be populated be  rename the image files where to  prefix the image original filename with a prefix image sequence number so the images will sort in the order you want them populated.  If you choose the can interactively populate template where you can chose the image you want in each location.  Once you choose an image the script will place in the image size it, position it and mask it the put you in an interactive Transform where you can tweak the smart object layer's image composition.

  1. Size your template the size you want - width, height and print DPI resolution.
  2. Photo collage templates must have a Photoshop background layer. The contents of this layer can be anything.
  3. Templates must have Image mapping alpha channels named "Image 1", "Image 2", ... "Image n".  size location  shape
  4. Layers above the background are optional but layers must provide transparent areas to let the images that will be placed below them show through.
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
Community Expert ,
Apr 04, 2018 Apr 04, 2018

Copy link to clipboard

Copied

There are free scripts the can do what you want...

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.

  1. Size the photo collage templates for the print size you want - width, height and print DPI resolution.
  2. Photo collage templates must have a Photoshop background layer. The contents of this layer can be anything.
  3. Photo collage templates must have alpha channels named "Image 1", "Image 2", ... "Image n".
  4. 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:

  1. HelpPhotoCollageToolkit.jsx - Online Help
  2. TestCollageTemplate.jsx - Used to test a Photo Collage Template while you are making it with Photoshop.
  3. CollageTemplateBuilder.jsx - Can build Templates compatible with this toolkit's scripts.
  4. LayerToAlphaChan.jsx - Used to convert a Prototype Image Layer stack into a template document.
  5. InteractivePopulateCollage.jsx - Used to interactively populate Any Photo Collage template. Offers most user control inserting pictures and text.
  6. ReplaceCollageImage.jsx - use to replace a populated collage image Smart Object layer with an other image correctly resized and positioned.
  7. ChangeTextSize.jsx - This script can be used to change Image stamps text size when the size used by the populating did not work well.
  8. PopulateCollageTemplate.jsx - Used to Automatically populate a Photo Collage template and leave the populated copy open in Photoshop.
  9. BatchOneImageCollage.jsx - Used to Automatically Batch Populate Collage templates that only have one image inserted. The Collage or Image may be stamped with text.
  10. 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.
  11. PasteImageRoll.jsx - Paste Images into a document to be print on roll paper.
  12. BatchPicturePackage.jsx - Used to Automatically Batch Populate Any Photo Collage template with an image in a source image folder.  Images Rotates for best fit.
  13. BatchPicturePackageNoRotate.jsx - Used to Automatically Batch Populate Any Photo Collage template with an image in a source image folder.
  14. PopulatePicturePackage.jsx - Used to Automatically populate a Photo Collage template Fill with the same single image and leave the populated copy open in Photoshop.
  15. PCTpreferences.jsx - Edit This File to Customize Collage Populating scripts default setting and add your own Layer styles.

Documentation and Examples

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
Explorer ,
Jul 24, 2018 Jul 24, 2018

Copy link to clipboard

Copied

Steps that I follow:

Open Photoshop – No documents are open. I click “Record” in actions I open my phone.PSD file (which opens up in a tab).

I open the .jpeg files (11 files at a time which open up in their respective tabs)

I click Ctrl+Tab in my phone.psd tab to move to my 1st jpeg file. I select all & copy.

On my phone.psd tab, I do paste of my copied jpeg into a layer above my sleeve layer.

I then do clip mask to create “Create clipping mask” (the jpeg is now shown on the phone layer shape).

I save the work done in the .psd to web -> File -> Save for web -> .jpg

I then delete the clipped jpeg layer on my phone.psd file which makes it ready for clipping of next jpeg.

I then do Ctrl+Tab to move to the jpeg which I had just clipped & closed the tab.

Recording ends.

Now, the problem is that whenever I run this batch, the batch runs fine BUT Photoshop renames the files with the same name and overwrites the previously clipped jpeg. The end result is that only the last clipped jpeg is available and that too with the 1st jpeg name.

Can anybody help me what is wrong or this is possible via js coding? or in the action method.

Michael Peterson

Clipping Path Associate

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 24, 2018 Jul 24, 2018

Copy link to clipboard

Copied

LATEST

You have most likely recorded your action with a save as step with hard coded file name recorded in the save as steps. If that is the case you need to re-record the Save as step and not change the file name that Photoshop defaults to. That will result in no file name being recorded into the save as step. When that step is played Photoshop will default the file name to the current Documents name. Not a fixed File Name recorded in the save as step.  Fully expand the Action so you can see what is recorded for each action step.  You do not want the seen any File name recorded in any save as step. Or you need to make the save as step interactive by turning on its dialog so you can set the file name you want to save what the step is played. A Photoshop script not an  action could contain logic the set the save as file name. Can you pogram in JavaScript?

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