Skip navigation
ocphotog
Currently Being Moderated

Insert Smart Images in Template

Aug 10, 2012 4:48 AM

I need a script that would let me place an image in a  template opening. I would like it to open a directory to choose the file to insert, resize it to fit the template opening, but keep it as a smart object so that it can be resized if necessary. I found this in this thread  http://forums.adobe.com/message/3329062      and     http://forums.adobe.com/thread/455645    and it seems to fit the bill but I cannot find any script that uses it. Can anyone direct me to something?  Thanks.

 

Stdlib.insertImageIntoSelectionAsSmartObject(doc, layer, im, fit)

 
Replies
  • Currently Being Moderated
    Aug 10, 2012 5:46 AM   in reply to ocphotog

    If you look at your first link you will see that code is provided by xbyor its part of his photoshop toolkit… Have you installed this?

     
    |
    Mark as:
  • Currently Being Moderated
    Aug 10, 2012 5:59 AM   in reply to ocphotog

    and you have the last parameter fit as false?

     
    |
    Mark as:
  • JJMack
    5,969 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 10, 2012 3:54 PM   in reply to ocphotog

    You could look at my Photoshop Photo Collage Toolkit

    Photo Collage Toolkit UPDATED June 12, added Picture Package Support via PasteImageRoll and BatchPicturePackage scripts.

     

    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 eleven 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. ChangeTextSize.jsx - This script can be used to change Image stamps text size when the size used by the populating did not work well.
    7. PopulateCollageTemplate.jsx - Used to Automatically populate a Photo Collage template and leave the populated copy open in Photoshop.
    8. BatchOneImageCollage.jsx - Used to Automatically Batch Populate Collage templates that only have one image inserted. The Collage or Image may be stamped with text.
    9. 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.
    10. BatchPicturePackage.jsx - Used to Automatically Batch Populate Any Photo Collage template with an image in a source image folder
    11. PasteImageRoll.jsx - Paste Images into a document to be print on roll paper.

     

    Documentation and Examples

     

    Note : there are Bugs in CS6;  Do not set your Pfererence to edit in Floating windows leave the option "Open documents in Tabs" checked  You must Also set your Photoshop Preferences Interpolation to something other then Photoshop's default "Bicubic Automatic" for adobe failed to add code for that change in to scripting.  If set to "Bicubic Automatic" when my scripts try to retrieve the interpolation preference a Photoshop internal error happens.

     
    |
    Mark as:
  • JJMack
    5,969 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 10, 2012 5:59 PM   in reply to ocphotog

    IMO Yes and give you more options to boot.

     

    What you want to do is more or less what the interactive populate collage script does. There is one difference the script picks the opening hihjlights the opening to be populated then put you in an image selection dialog when you select the image the script places the image into the opening transforming it to fit. Then it puts you in an interactive transform on the picture so you can tweak the transformed placement.

    Video Interactively Populated a Photo Collage Template  

     

    Message was edited by: JJMack

     

    The Script Dialog what you call a panel let you choose the Template to open and populate and  to set optons like Stamp File names in the images where the stamp should be on the image and if a text layer styles should be added to the text layers also  wether or not to add a layer styles to the smart object images layers.

     
    |
    Mark as:
  • JJMack
    5,969 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 11, 2012 5:36 AM   in reply to ocphotog

    Your templates most likely can be made compatable with my scripts. A backround layer is required but it dose not have to be visible. Its required for my script want to place in images above it and know they are  just above the bottom layer.  Your  templates must likely have layer mask or cutouts for images. All you need do is to make a selection that represents the size placement and shapes of your collage's images and save the selections as alpha channels named "Image 1", "Image 2" ... "Image N"

     

    Post one of your PSD template files  I'll have a look to see if they are easy to be made compatable with my scripts I find most templates are easy to be made compatable.  It would be way easier to make templates compatible then to program scripts to populate the kind of templates you now use. There are only four simple rules templates need to use.

     

    There is also an outside chance that the script LayerToAlphaChan.jsx - Used to convert a Prototype Image Layer stack into a template document. may be able to help make alpha channels for you.

     

    As for the starting folders for images and templates they can be anywhere there are hard coded variable in the scripts that you can change to suite your environment. All is spelled out in the help documentation.

    the scripts start with a section like this the last two vars are the defailt template and image paths.

    ////////////////////////////////////////////////////////////////////// ///////////

    ///////////////////////CUSTOMIZE Here////////////////////////////////////////////

    ////////////////////////////////////////////////////////////////////// ///////////

    // Some Hard Coded variables that some day I may put into the dialog options area

     

    var imageStyleList = ['Default Style (None)','Photo Collage Style 1','Photo Collage Style 2','Photo Collage Style 3','Photo Collage Style 4','Photo Collage Style 5','Photo Collage Style 6','Photo Collage Style 7','Photo Collage Style 8','Photo Collage Style 9'];

    var imageStyleDefault = 0;                              // imageStyleList index number

     

    var textSizeFactor = 4;                                        // > 1 scales down text size

    var textFont = "ArialMT";                              // Photoshop internal font name

    var textAngle = -10;                                        // center text angle

    var textColor = new SolidColor;                              // text color

        textColor.rgb.red = 255;

        textColor.rgb.green = 255;

        textColor.rgb.blue = 255;

    var textStyleList = ['Default Style (None)','Shiny Metal','Shiney Metal No Stroke','Strong Metal','Strong Metal No Stroke','Clear Emboss - Inner Bevel','Clear Emboss - Outer Bevel','JJMack Overlay'];

    var textStyleDefault = 0;                       // textStyleList index number

    var textLocationDefault = 7;                    // text Location Default Bottom Center

     

    var templateFolder = "C:/Program Files/Adobe/Adobe Photoshop Templates/";

    var imagePath = "~/My Documents/My Pictures/";

      // End hard coded variables

    ////////////////////////////////////////////////////////////////////// ///////////

    ////////////////////////////////////////////////////////////////////// ///////////

    ////////////////////////////////////////////////////////////////////// ///////////

     

    Message was edited by: JJMack

     
    |
    Mark as:
  • JJMack
    5,969 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 11, 2012 6:07 AM   in reply to JJMack

    If the script LayerToAlphaChan.jsx is able to convert your image layers to alpha channels there is a script in my crafting actions package that could be used to add background layer to templates that do not have background layers.

    Crafting Actions Package Contains

    Example

    Download

     

    The script named SelectBackground.jsx you may be able to record a Action that uses SelectBackground.jsx followed by LayerToAlphaChan.jsx Then batch that action to convert your templates in your Template folder to compatible templates in a new Template Folder.

     

    SelectBackground is a very siimple script

    // A Script by JJMack's Designed for use with Custom Mat Actions

     

    // This script targets the background if there is one or

    // adds a new tageted background layer if there wasn't one.

     

    // This script is supplied as is. It is provided as freeware.

    // The author accepts no liability for any problems arising from its use.

    /*

    <javascriptresource>

    <about>$$$/JavaScripts/SelectBackground/About=JJMack's Select Background.^r^rCopyright 2009 Mouseprints.^r^rScript utility for action.^rNOTE:Select Background adding one if need be!</about>

    <category>JJMack's Action Utility</category>

    </javascriptresource>

    */

     

    // enable double-clicking from Mac Finder or Windows Explorer

    #target photoshop // this command only works in Photoshop CS2 and higher

     

    // bring application forward for double-click events

    app.bringToFront();

     

    // ensure at least one document open

    if (!documents.length) {

              alert('There are no documents open.', 'No Document');

    }

     

    // if at least one document exists, then proceed

    else {

              main();

    }

     

    ////////////////////////////////////////////////////////////////////// /////////

    // main - main function

    ////////////////////////////////////////////////////////////////////// /////////

    function main() {

              try {

                        // declare local variables

                        var layers = activeDocument.layers;

                        activeDocument.activeLayer = layers[layers.length-1] // Target Bottom Layer

                        if ( activeDocument.activeLayer.isBackgroundLayer ) { return; } // quit

                        app.activeDocument.artLayers.add()

                        // declare local variables

                        var newlayers = app.activeDocument.layers;

                        // arrange layers so new layer added is at bottom

                    newlayers[0].move(newlayers[newlayers.length-1], ElementPlacement.PLACEAFTER);

                        // Make it a Background Layer

                        activeDocument.activeLayer.isBackgroundLayer=1

              }

     

              // display error message if something goes wrong

              catch(e) { alert(e + ': on line ' + e.line, 'Script Error', true); }

    }

     

     
    |
    Mark as:
  • JJMack
    5,969 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 11, 2012 8:02 AM   in reply to ocphotog

    You need to upload PSD to a site for sharing files you can also e-mail one as an attachment jjmacks@hotmail.com

     
    |
    Mark as:
  • JJMack
    5,969 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 13, 2012 11:57 AM   in reply to ocphotog

    Sent you e-mail with attachments an Action, a Script and a link to your sample template.  If you reverse the stacking order of your image layers before doint the conversion tmahes will pe populated from left to right. The way it is now images will be populated right to left.

    Images are populated above the background layer from the botton layer to the top image layer in the layer stack.

     
    |
    Mark as:
  • JJMack
    5,969 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 13, 2012 2:22 PM   in reply to ocphotog

    Adobe changed the was script are recorded in newer versions of photoshop. You will need to record the twi steps on your CS3

     

    In the Actions in the action palette in the action  you should see a Stop step followev by two script steps. Highlight the two script steps and drage them to the trash can in the Actions palette.

     

    Open one of your template files the in the Actions Palette highlight the Convert Template action and click the Play button.  The Action shouls play and stop after you click the stop button the delete current layer step should be highlighted. Hihglight the Stop step above it instead.

    The click on the record button.

    Use menu File>Scripts>SelectBackground

    Use menu File>Scripts>LayerToAlphaChan

    click on the stop recording icon in the action palette

    Highlight the ConvertTemplate action set

    Use the Actions Palette fly-out menu iten Save Action

    save the action set the action set should now work ou ypour CS3 system

     
    |
    Mark as:
  • JJMack
    5,969 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 13, 2012 5:04 PM   in reply to ocphotog

    Thing are backwards compatible it hard to make programs forward compatible for its has not been programmed yet. That is your case CS3 is not forward compatible with cs5. I had created the action with CS5. 

     

    I like CS5 way for I can install scripts in my script tree and link all Photoshop versions script folder to my install tree. That way all version of Photoshop the will look for Script by name will work.

     

    However CS2 and CS3 where my scripts will also work from the scripts menu if used in actions need to be recorded in actions in CS2 or CS3.  The Scripts location must never change and they must be install in the same location on all Machines. For CS2 and CS3 action player will not look for scripts by name they expect the scripts full path to be recorded in the action step..

     

    There is more flexability the new way actions work.  The Script are normally used from menu File>Scripts>List Script Name. Therefore scripts can be installed anywhere on one's system and as long as the location in linked into Adobe Photoshop Script Path they will be listed in the Scripts List by name and findable. Enen in actions recorded in CS4,5 or 6.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points