Replace smart object script

Disclaimer: I do not know how to script, but am willing to learn and am looking for advice.
I need to replace the text in a smart object from a data list then save the updated file using the smart object text. Is there an existing script that will do this?
I cannot use a straight text layer because I'm performing a free distortion warp on the smart object that does not work on straight text. Using variables seems like a logical solution, but the only variable type for smart objects is "visibility".
Plan "B" is to "replace smart object" with a series of PSD files containing the appropriate text. This works great, but I don't know how to automate it. I can easily create the series of PSD files using variables, but don't know how to automate their insertion into the template containing the distorted smart object.
I'm looking forward to learning something new!

I took a quick look at your script.
I do not know where the the displacement map come in,
The script seem the be replacing the object content of the current smart object layer.
That layer can have had all sort of photoshop functions associated with it and has an associated transform.  All smart object layer have an associated transform and may have smart filters and filter mask as well.
I see no code to handle the smart object size and make the replacement object have the same size or insure the replacement object is the aspect ratio and size.  Replacing  a smart object content does not change the current layer's associated the transform that transformed the original object. If the replacement object is not the same size as the original object the transform may not work like your expecting.
An associated displacement map may come into play because of smart filters on the smart object layer. Displacement  maps content are either for the layers content or for lower layers content to make the current layer to conform to lower layers contours.
In fact I create a four image picture package template that used a smart object for the image. Added CS2 for a file type that could be used to replace the image  in your script and ran your script.  It did pop up the ACR dialog if I select a raw file but it worked perfectly for my portrait cr2 files are the same size and aspect ratio. Ast the object.
And a jpeg was saved to my desktop.
When a different size landscape orianted portrait image is selected here is the result

Similar Messages

  • Batch Replace Smart Object With Different Image Quality and Sizes

    Hi there,
    I need help. I have this template that is in 1000x1000pixel and 300 dpi. I'm trying to replace the smart object inside with various JPEG that I have. These JPEG comes in large image sizes but lower than 300dpi. The issues is, when I run the script that I have, some of the pictures become really pixelated. Beforehand, I resized them to fit into the empty place in sizes that I find fit the best (8 cm x 6 cm). Some of them work okey, but then some of them just pretty bad. I'm wondering if you can help me fix the script that I have so I didn't have to resized the images before running the script, and for all of them to automatically fit into my template without altering the quality of the image that I put in.
    below is the script that I am using and the screenshot of my template:
    #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;*.jpg;*.jpeg;*.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[m], theLayer);
    var theNewName = theFiles[m].name.match(/(.*)\.[^\.]+$/)[1];
    //Raise color picker for Back cover;
    try {
    app.activeDocument.activeLayer = app.activeDocument.layers[app.activeDocument.layers.length - 1];
    // =======================================================
    var idsetd = charIDToTypeID( "setd" );
    var desc7 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
    var ref2 = new ActionReference();
    var idcontentLayer = stringIDToTypeID( "contentLayer" );
    var idOrdn = charIDToTypeID( "Ordn" );
    var idTrgt = charIDToTypeID( "Trgt" );
    ref2.putEnumerated( idcontentLayer, idOrdn, idTrgt );
    desc7.putReference( idnull, ref2 );
    var idT = charIDToTypeID( "T " );
    var desc8 = new ActionDescriptor();
    var idClr = charIDToTypeID( "Clr " );
    var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
    desc7.putObject( idT, idsolidColorLayer, desc8 );
    executeAction( idsetd, desc7, DialogModes.ALL );
    } catch (e) {};
    //save jpg;
    myDocument.saveAs((new File(thePath+"/"+theName+"_"+theNewName+".jpg")),psdOpts,true);
    ////// get psds, tifs and jpgs from files //////
    function getFiles (theFile) {
    if (theFile.name.match(/\.(psd|tif|jpeg|jpg)$/i) != null || theFile.constructor.name == "Folder") {
    return true
    ////// replace contents //////
    function replaceContents (newFile, theSO) {
    app.activeDocument.activeLayer = theSO;
    // =======================================================
    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

    Thank you for your answer.
    I was resizing it before from bigger image size to a smaller one (121 cm to 8 cm) which fit my template size. But the dpi remains in 72 which makes the picture pixelized.
    I am wondering if I can find a script that will keep the size of the first image that I put on the template for other images that I place, regardless the size they are imported to. Basically, how to make them all fit into the template regardless the size.
    Thank you for the info about the scripting forum. I will write there too.
    Sorry, I'm so new to this

  • Replacing smart object content using Droplets ???

    Hi,
    I have a .psd with a smart object as one of the layers.
    I could easily go to Layers>Smart Objects>Replace Contents...
    but I have a couple of thousand files to replace.
    Is there a way to create a droplet so i can just drop the files into it
    and it automatically replaces the content of the smart object
    then saves out a new file for me?
    This would help me tremendously.
    I would appreciate any help.
    Moo...

    In my opinion this task will need some Scripting unless the Layer-names and Layer-structure are identical in all the files.
    One should be able to include the Script in a Droplet, but one might just as well use a dialog within the Script itself, I guess.
    If you should find no other option you might be able to get some help in the Photoshop Scripting Forum.

  • How to automate replacing smart object from folder?

    Hello!
    I have a layout in CS6, with an image that is a smart object. I have a folder of jpgs, and need to make comps from each of the JPGs. At the moment I take the master, double click the smart object. Place in the source JPG from the folder I'm working on. Save, back in the master, I export the updated layout for web. Then repeat.
    What I'd like to do, is use an action or script, that I could point to the folder of JPGs, and have it automatically, update the smart object with the JPGs export the comp as jpg for all of them.
    Is there a way to do this without being a programmer?
    Thanks
    Maxi

    Here's screenshots of a solution that doesn't require a script. You'll need to manually open the layout doc then open the SO but everything else is automated by Batch. Make absolutely sure that the SO doc is active when starting to record the Action and when you launch Batch. That's necessary for the "Select previous document" and "Select next document" steps to refer to the correct docs.

  • Replace Smart Object content

    I have a photo template with a few smart object. The templated works fines when i perform a "replace content" command. I was trying to automated this with an action, however the action just places the same photo when i point it to a folder with many images. Is there method of having the action cycle through the images?

    You can't use the Replace Contents action step in a Batch to flow in a folder of different images unless you use a Javascript to direct it. That can get very complicated if you've never worked with it.
    Variables and Data Sets is the standard method of approach with many tutorials online.
    Video Layer framing is quicker and more versitle. You won't find any documentation on that method, will require more experimenting probably.
    If you're more comforable with just actions and batches, then you could try a different layer structure. Create an action that you can batch directly on the images that:
    - Selects all layers.
    - Convert to Smart Object (hopefully content is same size between files?).
    - Places your main background file as a SO.
    - Moves the main background SO to the bottom.
    - Transforms the original SO to the correct placement. (use a dummy layer to record or group before transform to properly record values).
    Before, you were batching the same Replace Contents statement on all files, when none of the files contained the Smart Object you wanted to affect. That's why it didn't work. Here, you are Batching the individual files, sending them to another folder, or overwriting them by 'Save and Close'. Your main content is placed underneath the contents of each file.
    Good luck,
    -f

  • Photoshop CS4 smart object template just overwrote a raw file - HELP

    So.  I've been working in Photoshop extensively for about 6 years now and I am well aware that nothing we do in Photoshop or Lightroom is supposed to overwrite a raw file.  I'm not talking about changing it to something a little lighter or darker, I'm talking about replacing a picture of one baseball player with another one - and the original? Gone. 
    Here's what happened: I have a poster template that contains several layers, 7 of which are smart objects.  I change the pictures in the template by right-clicking the smart object layer and selecting "replace smart object," browsing to the new image, selecting, and here is what SHOULD happen: the target picture opens in Adobe camera raw, I make some small edits, click done or okay or something similar, and that new image has replaced the old one in the template.  What DID happen was this: I followed the procedure above and selected my target raw file, the picture that was already in the template (the one I was trying to replace with my target file) opened in Adobe camera raw.  I thought - Hey, that's wierd!  Closed the ACR dialog and tried again.  Same thing happened.  I opened lightroom and saw - to my HORROR - that the target file had been changed to the same image that was in the template.
    If it clarifies: pictures of player A (who played in 2009) is in all of the smart object layers in my template.  I want to make that poster be of player B (who played in 2012) so I begin replacing all the smart objects.  When I get to the 3rd image in the poster template, Photoshop overwrites my raw file of player B with the smart object photo of Player A.  There were no photos of player A on the network drive that the picture of Player B was on.  But there's one now.  My raw file shows that it was modified about 10 minutes ago. 
    We tried undoing in Photoshop.  That did nothing.  We tried deleting the xmp file.  That did nothing.  We removed it from the lightroom catalog and reimported it.  It is now a picture of Player A from 2009 and my picture of Player B from 2012 is just gone. 
    Anybody have any idea what this could be and how we could avoid it in the future?
    Best,
    Jamey

    mojoimagery wrote:
    Now - JJ - when you say "overlay files" - what do you mean?  Because that feels like a good description for what happened.
    We performed no save operation at any point during the sequence of events that ended with the image in one raw file being replaced by the image in the smart object.
    As I wrote Smart Object layers embedded object is a copy of the original  and if you replace it you replace it with a copy of some other object. Embedded object are copies and independent from the original.  If after creating a smart Object layer who's embedded object is a copy of a raw file and its conversion settings. You change the original RAW files RAW conversion settings the smart object layer raw conversion setting are not changes for its a copy with independent raw conversion settings. When you replace a smart object layers contents you will replace the embedded object and you should replace it with an object the has the same pixel size and orientation. Because there is an associated transform for the object in the layer that is not replaced. The replacement is also a copy.  If the original smart object was created using  File Open where you choose a RAW file  ACR would open with the RAW files current conversion settings.  In ACR you can changes the setting then hold down the shift key to change the open image button to an Open Object button.  Using that button ACR will open a smart object layer in Photoshop the contents of the embedded object is a copy of the RAW file and the current ACR settings.  No File is written Photoshop is not a File Editor its a Document editor that has many data structures for different layer types.  When you replace the contents of a smart object you will be put into a "Place" file selection dialog if you choose a raw file it should have the same orientation as the image being replaced because of the associated transform. When you choose a RAW file ACR will open and you can change the conversion settings however there will be no Open Image button instead there will be an OK button.  There is also a save image button and you can save a RAW file that is a DNG file not a CR2 file. Like the DNG converter. If you click the OK button the embedded object in the smart object layer will be replaced with a copy of the selected RAW file and the current ACR settings. Again there is no file written Photoshop is not a File editor just the embedded smart object data is replaced in Photoshop smart object layer's data structure.
    I do not think the use of smart objects in you process caused what you are experiencing and because it only happens once an a while I feel its more likely caused by some human error made during the processing in those cases. I would look elsewhere for what causing the overlay. In the place file selection dialog it is possible to rename files perhaps even by accident. Programs like LR and Bridge can rename and copy files perhaps overlay other files.

  • How do I disable linked smart-object auto-update/refresh?

    Working in the CC3D features, I am constantly making changes to my bump map. Every time I step-backwards, or make a significant change to the bump texture (smart object?), CC auto-saves the layer. This specific file is a very very large document (3 gigs in the bump texture layer alone), and the 3D layer has lots of lights and is very complex. This auto-refresh/update really bogs down the time that it would take me to make my changes. I have a very fast machine (I know it's fast, I dont need to list my specs), and I have all shadows disabled.
    How do I disable linked smart-object auto-update/refresh?

    If you do not like a feature like smart objects there is nothing forcing you to use it. Use some other features to do what you want. Please don't ask Adobe to introduce bug into smart object support.
    You could work on your bump maps textures in external files. When your done some time in the future you could edit your project with the smart object layer and use replace smart object. Only then will all smart filters be applied to the smart layer with the replaced smart object.
    Or if by CC Auto save Layer you referring to CC Generate feature you can disable that feature.
    I have no idea what your referring to when you write "CC auto-saves the layer" being a feature. I know CC Generate will write layers out as web files but that more a Web feature then a 3d feature.  Where do you see your layer being saved?

  • Spot Channels & Smart Objects in Photoshop CS4

    Please Help!
    I am trying to replace a smart object in Photoshop CS4 with a .psd, pdf or tiff image that contains a spot channel and it is not being honored in Photoshop
    The Channel tab does not honor the "Spot Channel" from the replaced Smart Object image.
    Question is: How can I replace a Smart Object and hold the spot channel?
    Thank you

    I don't believe spot channels transfer from smart objects but there is a workaround.
    1. Select Smart Object Layer. Layer: Smart Objects: New Smart Object Via Copy
    2. Open the new smart object
    3. Load spot channel as a selection.
    4. Layer: New Fill Layer: Solid color.
    5. Hide or delete all other layers.
    6. Save and return to parent document
    7. Load the smart object layer as a selection and hide the layer
    8. Invert selection, save selection
    9. Change the new alpha to the appropriate spot color channel
    Let me know if that doesn't work.

  • Replace content of multiple Smart Objects

    Here's simplified version of my dilemma: (Photoshop CS5.1)
    A file contains 3 instances each of 2 unique Smart Objects. Is it possible to Replace Contents of all 6 objects so that they share a common source content?
    Seems simple. Doesn't work.

    The only other thing I can suggest is to post in the Photoshop Scripting forum to see if the scripting wizards there have a script to solve your issue. 
    (I couldn't script my way out of a paper bag myself.)
    http://forums.adobe.com/community/photoshop/photoshop_scripting

  • How to replace a Smart object content with folder of JPGs

    Greetings!
    Sorry if that title is not clear. I have a cover design template (see example). The image is a transformed Smart Object. I want to streamline my workflow.
    Say I have a folder of jpgs, and need to replace the smart object of the template with the new cover jpg, then save for web as a JPG comp. Repeat.
    I already have a nice "scale layer to current canvas size" script from Michael L Hale. Which would be necessary in case the jpg is larger or smaller than the Smart object's content it will replace.
    Any thoughts if this could be done?
    Michael's resize script is here: http://forums.adobe.com/thread/1233856
    Thanks
    Maxi

    Remember in that other tread I wrote you would need to take aspect ratio into account if you don't want distortion. You do not want distortion placing in images.   You also do not want to place in all image in canvas size.  If your images vary in size you do not want to replace the contents of a smart object layer for the smart object associated transform to work correctly you need the replace the embedded object with an object with exactly the same size of the original embedded object.
    Also in that other thread I gave you code from one of my Photoshop Photo Collage Toolkit.  You seem to be creating a collage. You man want to look at my Photo Collage Toolkit.
    Templates are very easy to create for my Toolkit's scripts to work, You just need to follow four simple easy rules.
    The Four Rules:
    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.
    So your template would be easy and look like this, Red rectangle outlines my scripts.
    You would then use one of the scripts like interactive popopulate select the template then hit create collage
    The script would the open the template copy it the go to full screen show you a cyan mask as to where the next image will be placed, And put you into an interactive select image dialog.
    Once you select the script will place in the image resize and position it the put you in an interactive transform so you can tweak the position and size. The Populated collage will remain open in Photoshop.
    Documentation and Examples

  • Smart Object Update Script?

    Hey guys,
    Okey here is the thing, i have lets say 10 .psd's that contain smart objects. I want to ask you, is it there any script for Photshop CS6, that can open all .psd files and reresh all smart objects? (simillar to the Image Processor Script that exports .jpgs)

    There is nothing to refresh imbedded Smart Object are copies independent stand on their own.  If you want to update the imbedded smart object you can. However you need to somehow create a process that will record what smart object layers in a document contain.  So when you update the original image you can reconcile you database query it for document that contains the copies in smart object layers. Then kick off a process to update the documents hit that will replace the contents of the involved smart object layers.

  • Script to load multiple linked smart objects to stack

    Hi
    we have a workflow where we work with exr images, and load about 15 of them at a time into a stack, then from there convert them into smart objects.
    As the linked smart objects is out this means we can replace a folder full of images and update them which would save opening up the psd and having to replace conent on all smart objects.
    but can't seem to find a way to load multiple smart linked objects in with out having to do 1 by 1.
    Is there a simple script to do this?
    Thanks

    I had asked Adobe about a modified script to do this, but at this time, they didn't seem interested in developing it.  Perhaps if more people ask for it they would add this feature, which would be extremely handy.  Don't know if anyone has come up with their own script for this yet, but I'm sure someone will.

  • Can you replace embedded smart object with linked smart object?

    Hi,
    I'd like to update some document to reflet the new workflow that linked smart object provide. I have made some transformation on those embedded smart object and would like to not have to redo all those so is there anyway way to replace those SO with the linked version of the same SO?
    TIA
    Jeff

    Hi,
    I'd like to update some document to reflet the new workflow that linked smart object provide. I have made some transformation on those embedded smart object and would like to not have to redo all those so is there anyway way to replace those SO with the linked version of the same SO?
    TIA
    Jeff

  • Scripting layer comp property of linked smart object

    How can I through script set the layer comp property of a linked smart object?
    More generally, how can I access a smart object and manipulate it as a document?  I know that I get smart object layers by looking at the kind property, but I don't know what to do with them once I get them.  I'd like to be able to cast the layer to a document object I guess.  Thoughts, anyone?

    Photoshop Feature Requests should be posted over at
    Photoshop Family Customer Community
    But before posting one look around whether one exists already on this issue and add your +1 if it does.

  • Smart Objects: How can I prevent resizing when replacing contents?

    There seem to be 2 kinds of smart objects:
    One kind where you can replace the contents, no matter what size it has and it will fit into the bounding box of the smart object which is already there.
    The other kind where this doesn't happen.
    Is there any way to control that behaviour? I found that in older PS-files, replacing contents always made the new content fit into the bounding box, but since CS3, the transformation stays the same which means I have to rescale the smart-object if the content-size has changed.
    Example:
    Imagine a game cover with screenshots on the back side. Now each screenshot is a smartobject.
    All Screenshots are at 640x480 (assumend the standard screen dpi of 72)
    Now I found them in a better resolution (1024x768, also 72dpi) and replace the old ones with "replace content".
    The old photoshop behaviour: Photoshop would fit the larger image to occupy exactly the same area than it's predecessor.
    The new behaviour: The whole Smartobject is enlarged by 160% (not the transformation parameters, the visual appearance.), I have to scale it down to make it fit to the old size.
    And I really wonder about having older and newer Photoshop-Files where these Smartobjects behave differently.
    Now did I miss something in the help section or is there a way to control this behaviour?

    Yes, fortunately, I am a Windows user, but I don't want to start a religious war here And it is also possible to run multiple versions of Adobe products simultaneously under Windows - why shouldn't that be possible? Currently I have CS3 and CS4 and somtimes use CS3 when CS4 is just too buggy to get the job done. Before that I had CS and CS2 on the same machine.
    But I wouldn't keep all versions back to PS 6.0 or CS, that would be a bit too chaotic and I'd had to spend days of installing if I get a new computer. I expect those programs to be a little bit backwards-compatible, so I don't have to use many different versions. And for Photoshop, this is mostly the case. It's just very tiny details like Smart Object resizing that seems to work differently.
    Otherwise I'm really happy that in CS4 I can finally link Masks to smart objects and apply warp and perspective on them, that's a big plus!

Maybe you are looking for

  • My iPhone no longer works with external speakers

    Since upgrading to the 3.0 software, my iPhone (the original 2G model) no longer works with the speakers I have, or with my DVD/surround system. Previously it worked fine! Has anyone else experienced this. I'm so disappointed, as I use the speakers/s

  • [SOLVED] bash help: rsync only if device mounted

    Hi, First bash-script here - the tldp.org-guide has gotten me somewhere already, but the final condition 'if rsync...' seems to fail and I don't know why. The script checks if the location to backup the files to is a mountpoint. If not, the script sh

  • 6800nu with diffrent bios

    sorry for my last thread but anyways i was just curious if anyone here tried to flash a 6800nu with a diffrent company bios like say evga or leadtek. do u guys still experience problems after the bios flash?

  • [SOLVED] sshfs - Hangs at different occations (reboot needed?)

    I'm using Thunar with gvfs and sshfs, both works fine and does the job. Only problem is that for some reason, sshfs when going back to a folder after a while (that's bookmarked if that matters) nothing happens, and if i try to "unmount" the remote fi

  • Airport Extreme Bases Station serial number not recognized

    I bought this today and tried to register it. Registration rejects my serial number. I checked carefully, both on the back of the base station and on the box, and I'm sure I got it right. Eventually it allowed me to register, but with the Part Number