Skip to main content
Participant
September 30, 2011
Question

Place images to a specific spot in a template

  • September 30, 2011
  • 7 replies
  • 13861 views

I am trying to create an action that will drop images into a specific spot in another document and save it with a certain file name. After the first image is dropped in and saved, I want my next image to do the same and so on. I have all my images cropped to the correct ratio and being pulled from a folder on my desktop. I have my template open in Photoshop where I want my images from that folder to be dropped into. Is this possible?

Any help is greatly appreciated!!

Melissa

This topic has been closed for replies.

7 replies

Participating Frequently
April 1, 2022

Can anyone help me with this script?

\\ TAMPLATE FILL IMAGE //
1) Select the layer
2) Selected layer name change
3) Select multiple image Drive path
4) Open image >Copy>Close>First Select layer>Paste>Convert smart Object>Create clpping mask> fit to frame>Select layer name change

**Similarly selected layers will be filled

Stephen Marsh
Community Expert
Community Expert
April 1, 2022

@SUBIR PVL wrote:

Can anyone help me with this script?

\\ TAMPLATE FILL IMAGE //
1) Select the layer
2) Selected layer name change
3) Select multiple image Drive path
4) Open image >Copy>Close>First Select layer>Paste>Convert smart Object>Create clpping mask> fit to frame>Select layer name change

**Similarly selected layers will be filled


 

I would suggest that you make a new separate post, as it apparently has nothing to do with this topic.

 

Is it safe to assume that you don't know how to script?

JJMack
Community Expert
Community Expert
July 31, 2018

Templates are normally for Pictures and text not for populating shapes.    To make  a Photo collage template for what you show for Photo images would only require a empty Background, ten Alpha channels to map the Image Locations, Sizes and their Shapes.  On top of the background layer you would add your Text Layer and confine the text to the center area where your image will not be located, or you can add text over the image areas to overlay you image that will be placed in below the text.   I would not know how to populate a template with shapes.

Scripts can also add text layer on image like filenames. And layer styles can be added to populated image layers.  You can customize my scripts and add your additional layers styles.  Like A stroke around a image.

Smart Object layer are not additional work but they do have a higher overhead then a pasted in layer.   Smart object Layer can be tweaked, resized etc image quality will be preserve using Smart Object layers. Normal pixels layers do not have the same attribute as a smart object layer.

The Template  I used Dropbox - 10-Image.psd the template PSD is 12" x 12" with a 300DPI resolution.  The Portrait image locations have an aspect ratio near 2:3 the populated image will be 2.8" by 3.8" at a 300DPI resolution.

]

A video running one of my scripts.

JJMack
AG_Ps_100
Inspiring
July 31, 2018

guys you gave solutions but do you think a solution for my template can work?

I have a template that i've put 10 rectangle shapes (black fill with 4px white stroke) and then i create clipping mask:

i don't mind using Smart Object as well, although it might be more work.

automating this will be awesome.

Stephen Marsh
Community Expert
Community Expert
July 30, 2018

Melissa, I know that you are now sorted, however this may help somebody else. Sometimes you need scripts, other times all you need to do is look at the problem from a different angle and an action will do the job. I can’t write scripts from scratch, so I usually have to rely on actions.

Rather than attempting to insert the variable named/content files into a static template – place the static template into the variable files! This will preserve the critical variable filename. You will probably need to rearrange the layer order using relative layer targeting and stacking. The variable files can be sized to include the template and the template location and placement can be recorded and used on all variable files as this does not change. Elements can be aligned and moved to specific relative or absolute positions.

Example here:

Re: Simple action to replace image from walls

Kukurykus
Legend
July 30, 2018

One time visitor. She didn't check what people answered to her question since question was more important than answer?

c.pfaffenbichler
Community Expert
Community Expert
September 30, 2011

Recently I’ve done something similar, so I could adapt that.

On the lower left are the files that were selected in the Script’s dialog (all the same size, though), on the lower right are the resultant images, top center ist the template document with the Smart Object selected.

If you want to give it a try, paste the following text into a new file in ExtendScript Toolkit (part of Photoshop’s installation, /Applications/Utilities/Adobe Utilities-CS5/ExtendScript Toolkit CS5) and save it as a jsx-file into Photoshop’s Presets/Scripts-folder.

// replace smart object’s content and save psd;

// 2011, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

var myDocument = app.activeDocument;

var theName= myDocument.name.match(/(.*)\.[^\.]+$/)[1];

var thePath = myDocument.path;

var theLayer = myDocument.activeLayer;

// psd options;

psdOpts = new PhotoshopSaveOptions();

psdOpts.embedColorProfile = true;

psdOpts.alphaChannels = true;

psdOpts.layers = true;

psdOpts.spotColors = true;

// check if layer is smart object;

if (theLayer.kind != "LayerKind.SMARTOBJECT") {alert ("selected layer is not a smart object")}

else {

// select files;

if ($.os.search(/windows/i) != -1) {var theFiles = File.openDialog ("please select files", "*.psd;*.tif", true)}

else {var theFiles = File.openDialog ("please select files", getFiles, true)};

if (theFiles) {

// work through the array;

          for (var m = 0; m < theFiles.length; m++) {

// replace smart object;

                    theLayer = replaceContents (theFiles);

                    var theNewName = theFiles.name.match(/(.*)\.[^\.]+$/)[1];

//save jpg;

                    myDocument.saveAs((new File(thePath+"/"+theName+"_"+theNewName+".psd")),psdOpts,true);

                    }

          }

}

};

////// get psds, tifs and jpgs from files //////

function getFiles (theFile) {

     if (theFile.name.match(/\.(psd|tif)$/i)) {

          return true

          };

     };

////// replace contents //////

function replaceContents (newFile) {

// =======================================================

var idplacedLayerReplaceContents = stringIDToTypeID( "placedLayerReplaceContents" );

    var desc3 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

    desc3.putPath( idnull, new File( newFile ) );

    var idPgNm = charIDToTypeID( "PgNm" );

    desc3.putInteger( idPgNm, 1 );

executeAction( idplacedLayerReplaceContents, desc3, DialogModes.NO );

return app.activeDocument.activeLayer

};

SarahFaithMorris1600
Known Participant
January 30, 2014

I can't figure out how to get this script to be able to open a folder.  When I run it , it's only letting me select PSDs on my desktop.  I'd like to be able to select files within a certain folder.  Can I change something to make it stop ghosting out folders in the opendialog command?

schroef
Inspiring
February 6, 2018

What does not work?

Please post the Script you use and a screenshot of Photoshop (including the pertinent Panels) at time of the error.


Re: Place images to a specific spot in a template

This wont work, i dont get to pick a folder nor does go to a folder. Tried both methods. I keeps showing files only.

But im not even sure this what i was looking for, it seems this script places links in open images according do a selected llist from file selection.    

c.pfaffenbichler
Community Expert
Community Expert
September 30, 2011

Personally I would prefer to use a template with a Smart Object in such a case and Replace Contents.

What formats are the images to be placed, in which format what do you want the layered files saved, where to and with what names exactly?

JJMack
Community Expert
Community Expert
September 30, 2011

When replacing contents you will have to resize the replaced contents if the replacement image is not the same size and aspect ratio as the smart object contends being replace. There is a transform associated with a smart object layer.  The original smart object layer has a transform associated with it and that transform will be applied to the replacement image.  In fact if you dupe the smart object layer not using new smart object via copy. Just a strait layer dupe you can have several layers all containing the single smart object with each layer having its own transform which locates its position and size. Replacing the content of any of those layers smart object changes the image on all the layers.  For a this type or collage to work correctly the original smart object image and the replacement need to be the same size.  I use Place and smart Object in my Photo Collage Toolkit.   I like to support any size image the only important thing is an image aspect ratios should closely match the aspect ratio of the template image aspect ratio.  They don't have to be same aspect ratio the scripts will fit all image into place but the apparent crop can adversely effect image composition.  Being they are smart objects they can be tweak by retransforming the placed image placement and size.

JJMack
c.pfaffenbichler
Community Expert
Community Expert
October 1, 2011

Nice explanation for the OP.

And the point you made in post 1 about integrating Scripts into Actions for the steps where Actions alone would fall short is also a valid one – but if in this case the names of the selected file is to be used for saving the new file it might be inconvenient if the selection and the saving would have to be done at two separate points in the Action.

JJMack
Community Expert
Community Expert
September 30, 2011

Melissa

What you want to do can be done but it is complex and actions have some limitations and can not use logic without using a script or two. File saving  can be tricky for an action will always save the same file name or use the current document name saved either overwriting the file or saving it to some other particular folder. Action that populate a template can be created but it will always populate the same number of images because an action can not use logic to find out how many spots there are to populate. There are different ways to drop an image into the active document you can paste into an area or just past in the image in as a new layer.  You can also Place images in as smart objects. Each method has some advantages and disadvantages. Layers can also be aligned with selections and layers can be transformed in size.  Your best off creating rule for creating a template and have a plan as to how your going to populate these templates that follow your rules. To protect the template from alteration you may want to dupe the template close the original and work on the duped version. When you dupe the template you can give the dupe a name if you do not name it the new document will have the same name with copy appended.

Scripting is more powerful then Action but they are programs that are written in a scripting language. Photoshop supports three languages. VBS, Applescript and Javascript. Only Javascript is supported on both the MAC and PC platforms.  Even using Javascript you may need to code the script to work on both platforms for I'm sure there are some differences in the OS and file system the may need special handling to work on both platform.  From you description of you work-flow it is hard to tell exactly what you are doing.   If you trying simple create a photo Collage.  You may want to have a look at my free Package for Photoshop called "Photo Collage Toolkit" . I have been told this package works on a MAC but I created it and tested it on widows and got it To work with CS2, CS3, CS4 and CS5.

.

Photo Collage Toolkit UPDATED Sept 24, 2011 added a script to replace a Populated Layered Collage Smart Object Image with an other image with resizing.

Photoshop scripting is powerful and I believe this package demonstrates this.

The package includes four simple rules to follow when making Photo Collage Template PSD files so they will be compatible with my Photoshop scripts.

There are eight scripts in this package they provide the following functions:

  1. TestCollageTemplate.jsx - Used to test a Photo Collage Template while you are making it with Photoshop.
  2. CollageTemplateBuilder.jsx - Can build Templates compatible with this toolkit's scripts.
  3. LayerToAlphaChan.jsx - Used to convert a Prototype Image Layer stack into a template document.
  4. InteractivePopulateCollage.jsx - Used to interactively populate Any Photo Collage template. Offers most user control inserting pictures and text.
  5. ReplaceCollageImage.jsx - use to replace a populated collage image Smart Object layer with an other image correctly resized and positioned.
  6. PopulateCollageTemplate.jsx - Used to Automatically populate a Photo Collage template and leave the populated copy open in Photoshop.
  7. BatchOneImageCollage.jsx - Used to Automatically Batch Populate Collage templates that only have one image inserted. The Collage or Image may be stamped with text.
  8. 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.

Note: Rags Gardner www.rags-int-inc.com Photoshop Collage Template Builder script Copyright (c) 2006 builds layered Photo Collage Template psd files. Rags's has given me permission to include a modified version of his script in my package. The modification converts Rags's layered image template document into a flattened template compatible with Photoshop "Photo Collage Toolkit" package. There is also an option that will instead create a layered image stack like Rags's templates are these are also produced if you attempt to create a template with more then 53 images.

Photoshop only supports up to 53 Alpha channels therefore with its design the Photo Collage Toolkit can only support collages with 1 to 53 images. I do not feel this is a big limitation for if you put 53 3:2 aspect ratio images on a large 16" x 20" paper they would need to be less then 1.9" x 2.86" in size if you wanted a frame around each and less then .95" x 1.43" on a 8" x 10" year book page size.

While the maximum number of images in a collage is 53 you can actually create larger collages by populating a large number of images into several collages and then populate yet an other collage template with these populated collages. Each will be placed into the collage of collages as a single smart object layer. You may want to save the populates PSD file as Jpeg files first to cut down on the overhead of having large PSD file smart object layers in the collage of collages.

Documentation and Examples


JJMack
Known Participant
January 30, 2016

Thank you , JJ Mack!!! I have wanted to do this same thing Sara describes - For me I wanted to quickly and easily create Folder Preview Image JPEGs using several images inside of the folder. I was able to easily make an action to resize the images and save them to a folder. But I never fully figured out how to get those images on to my various templates (8 images, 16 images, etc...) and clipped to the masks. Your scripts are magical to me! I am not someone who knows how to script but I knew enough to know this was the best way to achieve what I wanted. Your Tool Kit and postings had great instructions and videos and have made one of my Mac tasks SO simple and such a time saver. THANKS!!