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

Running a script within an action

New Here ,
Jan 27, 2019 Jan 27, 2019

Copy link to clipboard

Copied

I'm trying to achieve a very specific, easy but time consuming task with Photoshop, but I'm very much a beginner to the action / scripting side of things, my only frame of reference is that it might be like Macros in Excel. Mainly I was hoping to run a couple of ideas past the forum, and some expert might be able to tell me if I'm barking up the wrong tree, or if I'm onto something.

I've got to put labels on jars of sweets using Photoshop. I've got 30-odd varieties of sweets, each with 3 different sized jars, and 40-odd labels.

What I've done so far is put all of my labels into a Smart Object. This allows me to warp the labels around my jar naturally. I've then put every iteration of the jars in my Photoshop document. I've made every iteration into a group, and within each group I've put a copy of the Smart Object label, perfectly placed over the jar.

I've found a bit of script that will then take every group, and save it as a jpg in a file of my choosing.

The time consuming bit is that every . time the script runs, I then have to go to the Smart Object, turn off the top layer, to reveal the next label, and then run the script again. That sounds like a quick process, but the file is so big now, that it takes about 10 minutes just to save the Smart Object, and update the 120-odd instances of the Smart Object, then it takes another 10 minutes for the script to save 90-odd jpgs. And I've got to do this for 41 labels, with 50-odd more coming each month.

I was hoping I might be able to create an action that goes into the smart object, finds the next visible layer and turns it off, copies the name of the layer, saves the Smart Object, runs the script, uses the copied name as a file extension, and then repeats until it's run out of visible rows. Then it can take as long as it wants, and I can leave it running overnight.

Does that sound possible? Is it there a more efficient way of achieving the same result?

Thanks in advance.

Views

7.0K

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
LEGEND ,
Jan 27, 2019 Jan 27, 2019

Copy link to clipboard

Copied

Look up data-driven graphics. You would save the labels out at separate files, create a spreadsheet that specifies which label graphic goes with what, and create a master image that has the data set imported. If I had to do this every month, that would be my first idea.

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 ,
Jan 27, 2019 Jan 27, 2019

Copy link to clipboard

Copied

Be aware the Data driven graphics does not support replacing Smart Object layer objects.  Your Template can contain Smart Object layers  as part of its design. However Data Driven graphics support replacing raster image layers and text layers. 

Script and actions can include other scripts and actions in their processing. Script can use other Scripts.  Action can play actions a record menu file>scripts>script names steps.  Script's can include other script and use function in the included script. Script cam plat action using Doaction statements.

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 ,
Jan 28, 2019 Jan 28, 2019

Copy link to clipboard

Copied

Can you post screenshot with example. Please include and Layers panel.

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 ,
Jan 28, 2019 Jan 28, 2019

Copy link to clipboard

Copied

Here's a screen shot. You can see what the eventual image is supposed to look like (there's also one version with just the small jar, and one with the large jar), so each sweet type has 3 groups, and 4 layer images in total. And you can see the layers panel here.

As an added bonus, you can also see the steps in the action I've created.

I was actually very proud of myself. I was up . til 3am creating an action using really obscure keyboard short cuts that I had to look up, and theoretically it works perfectly. I even found some script that would then run that action as many times as I specified. And based on answers here, I was able to run my Save Groups To JPGs script as part of the action. But it gets as far as running the script, but the script requires me to set a save location in a dialogue box. While recording the macro, I did all this with keyboard shortcuts, but the action isn't picking any of that up. I tried experimenting just keeping to the defaults and pressing okay, but the action won't even click okay for it, I have to go back to my MacBook every 20 minutes to click okay manually.

Is this just a case of the script not being compatible with the action, and it never will be, or is there some secret I'm missing.

I appreciate the advice about Data Driven graphics, but that seems like another level of . learning beyond where I currently am. I can just about get my head around Actions, as I do a lot of work with Macros in Excel. This is almost working, and would work perfectly if it wasn't for that one step in the script.

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 ,
Jan 28, 2019 Jan 28, 2019

Copy link to clipboard

Copied

Can you post a link to the script or paste in the script code (use the forum reply editor in advanced mode and syntax highlighting on the code).

It should just be a case of changing the dialog step/s to either use a hard coded save path or a relative save path from the input file.

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 ,
Jan 28, 2019 Jan 28, 2019

Copy link to clipboard

Copied

That sounds good. I wondered if a tweak to the script might help. I'm good at html and css, but java passed me by a bit. This was offered up somewhere on this forum, so I'm terrified if I tweak it it will break it irreparably.

The other issue I have is that the layers in the labels smart object are all correctly labelled with their own unique codes. So I've included in the Action to select the layer, go to Layers > Rename Layer, use Alt+Shft+right to select the code, then Cmd+C. When I've come to the dialogue box for the script, it's got an option to append something on the default name, so I've used Cmd+V to paste in this label code.  I've also used that to find the appropriate folder, with Cmd+Shft+G. But I believe that has fallen at the first hurdle and not actually copied the layer name in the first place (not that anything to do with the dialogue box seems to work anyway).

I've realised that if I just keep all the default locations and names from the script, then if I repeat it, then it'll just keep overwriting the files, so it definitely needs this ability to make the file names unique, or save them all in different folders.

// creates pdf-copies of layersets with dialog to select layers and suffix;

// be advised: existing files of identical names will be overwritten without warnings;

// 2009, pfaffenbichler, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

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

// get document-path and -title;

var myDocument = app.activeDocument;

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

var myPath = myDocument.path;

var theLayerSets = collectLayerSets(myDocument);

////// filter for checking if entry is numeric, thanks to xbytor //////

numberKeystrokeFilter = function() {

this.text = this.text.replace(",", "");

this.text = this.text.replace(".", "");

if (this.text.match(/[^\-\.\d]/)) {

this.text = this.text.replace(/[^\-\.\d]/g, "");

};

if (this.text == "") {

this.text = "0"

}

};

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

// create the dialog;

var dlg = new Window('dialog', "pdfs from layersets", [500,300,930,840]);

//create list for layer-selection;

dlg.layerRange = dlg.add('panel', [21,20,279,445], "select layersets to create pdfs of");

dlg.layerRange.layersList = dlg.layerRange.add('listbox', [11,20,240,405], '', {multiselect: true});

for (var q = 0; q < theLayerSets.length; q++) {

dlg.layerRange.layersList.add ("item", theLayerSets.name);

dlg.layerRange.layersList.items.selected = true

};

// entry for suffix;

dlg.suffix = dlg.add('panel', [290,20,410,85], "enter suffix");

dlg.suffix.suffixText = dlg.suffix.add('edittext', [11,20,99,40], "", {multiline:false});

// entry for number;

dlg.number = dlg.add('panel', [290,100,410,165], "start with #");

dlg.number.startNumber = dlg.number.add('edittext', [11,20,45,40], "1", {multiline:false});

dlg.number.addNumber = dlg.number.add('checkbox', [55,20,105,40], "add", {multiline:false});

dlg.number.startNumber.onChange = numberKeystrokeFilter;

// field to add layer-name;

dlg.layerName = dlg.add('panel', [290,180,410,270], "layer-name");

dlg.layerName.doAddName = dlg.layerName.add('radiobutton', [11,20,120,40], "add it");

dlg.layerName.dontAddName = dlg.layerName.add('radiobutton', [11,45,120,65], "don’t add it");

dlg.layerName.doAddName.value = true;

// field to select target-folder;

dlg.target = dlg.add('panel', [290,285,410,445], "target-folder");

dlg.target.targetSel = dlg.target.add('button', [11,20,100,40], "select");

dlg.target.targetField = dlg.target.add('statictext', [11,50,100,155], String(myPath), {multiline:true});

dlg.target.targetSel.onClick = function () {

var target = Folder.selectDialog("select a target folder");

dlg.target.targetField.text = target.fsName

};

// ok- and cancel-buttons;

dlg.buildBtn = dlg.add('button', [220,460,410,475], 'OK', {name:'ok'});

dlg.cancelBtn = dlg.add('button', [21,460,210,475], 'Cancel', {name:'cancel'});

dlg.warning = dlg.add('statictext', [21,490,410,530], "be advised: existing files of the same name will be replaced without prompting", {multiline: true});

dlg.center();

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

var myReturn = dlg.show ();

// in case of OK;

if (myReturn == true && dlg.layerRange.layersList.selection.length > 0) {

// get the number instead of the name;

var theLayerSelection = new Array;

var theColl = dlg.layerRange.layersList.items;

for (var p = 0; p < dlg.layerRange.layersList.items.length; p++) {

if (dlg.layerRange.layersList.items

.selected == true) {

theLayerSelection = theLayerSelection.concat(p);

}

};

// collect the rest of the variables,

var theSuffix = dlg.suffix.suffixText.text;

var theNumber = Number (dlg.number.startNumber.text) - 1;

var theLayerNameAdd = dlg.layerName.doAddName.value;

var theDestination = dlg.target.targetField.text;

var theNumbering = dlg.number.addNumber.value;

// pdf options

var jpgopts = new JPEGSaveOptions();

jpgopts.embedColorProfile = true;

jpgopts.formatOptions = FormatOptions.STANDARDBASELINE;

jpgopts.matte = MatteType.NONE;

jpgopts.quality = 10;

// create the pdf-name;

if (theSuffix.length > 0) {

var aSuffix = "_" + theSuffix

}

else {

var aSuffix = ""

};

// create a flattened copy;

var theCopy = myDocument.duplicate("thecopy", true);

// do the operation;

for (var m = theLayerSelection.length - 1; m >= 0; m--) {

app.activeDocument = myDocument;

var theLayer = theLayerSets[theLayerSelection];

if (theNumbering == true) {

theNumber = bufferNumberWithZeros((Number (theNumber) + 1), 2);

theNumberString =  "_" + theNumber

};

else {

theNumberString = ""

};

// get the layername for the pdf-name;

if (theLayerNameAdd == true) {

var aLayerName = "_" + theLayer.name.replace("/", "_")

}

else {

var aLayerName = ""

}

// transfer layerset over to the copy;

theLayer.duplicate (theCopy, ElementPlacement.PLACEATBEGINNING);

app.activeDocument = theCopy;

// hide the llast added layer;

theCopy.layers[1].visible = false;

theCopy.saveAs((new File(theDestination+"/"+myDocName+aSuffix+aLayerName+theNumberString+".jpg")),jpgopts,true)

};

theCopy.close(SaveOptions.DONOTSAVECHANGES);

}

};

else {alert ("no document open")};

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

////// buffer number with zeros //////

function bufferNumberWithZeros (number, places) {

var theNumberString = String(number);

for (var o = 0; o < (places - String(number).length); o++) {

theNumberString = String("0" + theNumberString)

};

return theNumberString

};

////// function collect all layersets //////

function collectLayerSets (theParent) {

if (!allLayerSets) {

var allLayerSets = new Array}

else {};

for (var m = theParent.layers.length - 1; m >= 0;m--) {

var theLayer = theParent.layers;

// apply the function to layersets;

if (theLayer.typename == "ArtLayer") {

// allLayerSets = allLayerSets.concat(theLayer)

}

else {

// this line includes the layer groups;

allLayerSets = allLayerSets.concat(theLayer);

allLayerSets = allLayerSets.concat(collectLayerSets(theLayer))

}

}

return allLayerSets

};

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 ,
Jan 28, 2019 Jan 28, 2019

Copy link to clipboard

Copied

Forum member c.pfaffenbichler created that script, he should receive an email that his name has been mentioned in this post… Let’s see what he has to say.

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 ,
Jan 28, 2019 Jan 28, 2019

Copy link to clipboard

Copied

I can not see all of your layers palette.  So I do not know you template structure.  However it look like you are trying the replace labels on two jars with the same label sized for the different size jars and warped perceptively onto the jars surface.  If all output image are of those  two candy filled jars with different labels all you would need is a collection of labels that have exactly the same Size, Aspect Ratio and Resolution.  You could batch replace a top Smart Object Layers Object content and save an output image with each replacement .  Two other smart object layers would share the top smart object layer's object and transforms and warps  the object for two jars labels. No spread sheet or CSV file required.  Just a folder of replacement labels  a template and a script is required.

Capture.jpg

A script like this may do.

var theFiles = null; 

 

try {   

    if (app.documents.length > 0)  

        {   

        var myDocument = app.activeDocument;   

        try { var theName = myDocument.name.match(/(.*)\.[^\.]+$/)[1]; } catch(e) { alert(e); }   

        var thePath = myDocument.path;   

        var theLayer = myDocument.activeLayer;   

        psdOpts = new PhotoshopSaveOptions();   

        psdOpts.embedColorProfile = true;   

        psdOpts.alphaChannels = true;   

        psdOpts.layers = true;   

        psdOpts.spotColors = true;   

 

        if (theLayer.kind != "LayerKind.SMARTOBJECT")  

            {   

            alert("selected layer is not a smart object")   

            }  

        else  

            {   

            var folder = Folder.selectDialog("Select folder", "C:\\");   

            if (folder) theFiles = folder.getFiles(/\.(psd|tif|jpg|png)$/i);

            //alert(theFiles.length);

   

            if (theFiles)  

                {   

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

                    {   

                    theLayer = replaceContents(theFiles, theLayer);   

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

                    var jpegOptions = new JPEGSaveOptions();   

                    jpegOptions.quality = 10;   

                    jpegOptions.embedColorProfile = true;   

                    jpegOptions.matte = MatteType.NONE;   

                    myDocument.saveAs((new File(thePath + "/" + theNewName + ".jpg")), jpegOptions, true);   

                    }   

                }   

                }   

            }   

    }    

catch(e) { alert(e); }   

 

if (theFiles) alert("Processed " + theFiles.length + " files");   

else          alert("No files found");   

 

function replaceContents(newFile, theSO)  

    {   

    try {   

        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   

        }    

    catch(e) { alert(e); }   

    }   

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 ,
Jan 29, 2019 Jan 29, 2019

Copy link to clipboard

Copied

Thank so much for taking as look at that. It never ceases to amaze me, the kindness of strangers on forums.

Looks like we're onto something here.

So I can just do replace contents on the top smart object, which is hidden, and then all other warped and adjusted instances of the label will be replaced.

I'm trying to decipher the script though. Does that automatically replace the image with the next label in the folder, then save the template, then move onto the next one?

If I've understood that correctly, then we're close, but no cigar yet. The problem  is that I still need c.pfaffenbichler's script incorporated somehow, because I still need to save each group as an individual JPG.

If you could see the whole layer palette, you'll see that there are about 90-odd groups at the minute, 30-odd different varieties of sweets, and 3 different images of each (a small jar, a large jar, and the two jars together). More varieties of sweet will be added eventually.

Currently I can only this script working if I set up 90-odd different template files, and then I'd have to open each file and run the script.

If the sweets were all in exactly the same place, I found a script that would enable me to put the jars in one group, and the labels in another, as separate layers, and then it would save every combination. But, unfortunately, that's not how the photographer did it, so there needs to be a separate label layer for each jar image, so I can slightly nudge it around and make sure it lines up right.

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 ,
Jan 29, 2019 Jan 29, 2019

Copy link to clipboard

Copied

You would open your template output jpg files will be saved into the folder the template psd file is in. You can change the script if you want to save  your jpg files else ware.  When you open the template the top layer will be the current tagger so you can run the script and select the labels folder that has your labels. You can record actions that would open a template and run the script.  Your template can have the 90 other layers what ever structure you need,  Having the hidden top smart object layer just make it easy to replace the single object used. If you also want to automate  different jar fill content that a different story.  To may want to create a script to create template psd file the have jars with different content.  Of has groups the have the different content in a single PSD template the you sane PSD file that have the label replaced the you can to selected which content you want visible.   I created a  Baseball Photo collage template where I can edit  and change some of the saved output psd files to change elements in the baseball cards saved.  Change which layer are visible.

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
Community Expert ,
Jan 29, 2019 Jan 29, 2019

Copy link to clipboard

Copied

My Photo Collage Toolkit Scripts place in image and resizes the placed in image to fill the images area and mask off any excess. The scripts  can also stamp the image's filename on the populated collage.  My scripts always saved PSD files populated with the images and optional text.  Layer styles can also be added to the Images and text layers populated.  So Template can be customized before being populated and populated  template PSD files can be changed and tweaked easily with Photoshop.   My Template are not populated using Replace Smart object layers content.  Template do not contain prototype image.  They just have alpha channels that map where image are to be located their size and shape.   My scripts place in imaged and  resize them to fill the mapped area, position to the mapped area and mask to the mapped area.  Up to 53 images can be populated into a collage template for Photoshop only supports 53 Alpha channels.

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
Community Expert ,
Jan 29, 2019 Jan 29, 2019

Copy link to clipboard

Copied

I do not like replacing Smart object contents populating mockup for all replacement images need to be  preprocessed. so they will populate correctly.  Replace Smart Object Layers content use Photoshop "File Place Image" Photoshop Place feature is weird and IMO not design well.  For it may resize you image for the layer and it may scale the smart object layer to fit one canvas.   I do not mind that it may scale the smart object layer the fit on canvas depending on how you have you preference set.  The wording of the prefences is miss leading. No matted how the setting is set Place may resize your image and it may also scale the resize the layer created denengint on the setting   However I do mind Photoshop resizing my image for the looses some image quality..  For some unknown reason to me if the file image being places in print resolution setting  is different the the open document print resolution setting Photoshop will resize you image which degrades its quality.  IMO that resize is bogus it should not be done.  Duplicate layer. drag and drop, copy and paste do not resize why in the world does place.  The is also causing problems in Photoshop poor new frame feature. Its using place and therefor has issues.

Replacement object need the be exactly the same size. That is have the same number of pixels wide and same number  of pixels high and have the same print resolution as the object stored in the mockup template,   So the place will create the same size object. Every Smart Object layer has an associated transform for the layer the transform the layer to size. The associated transform is not replaced or changed when you replace the a layer object.  You mockup type has three smart object layers the share a single object.  There are three different associated transform for the single object.

Mockup for picture packages and prioduct designs  where image need to be distored be warped, rotated, perspective or other  distortions smart object repacement is the way to go but require preprocessing replacement image.

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 ,
Feb 03, 2019 Feb 03, 2019

Copy link to clipboard

Copied

Sorry for not getting back promptly, I've just come back from holiday. Thanks for looking into this in such depth. It is starting to go a little over my head though.

What I have realised though, is that the original code I'm using can work, (perhaps not the most efficient way), with just a couple of small tweaks.

For example, my limited abilities have enabled me to take out the original filename and the underscores from the newly created filename, which is more aesthetically desirable for my purposes, but not not particularly useful as part of the automation process, but it makes me feel a bit better that I'm familiar enough with the code to be able to tinker.

// entry for suffix;

dlg.suffix = dlg.add('panel', [290,20,410,85], "enter suffix");

dlg.suffix.suffixText = dlg.suffix.add('edittext', [11,20,99,40], "", {multiline:false});

// field to select target-folder;

dlg.target = dlg.add('panel', [290,285,410,445], "target-folder");

dlg.target.targetSel = dlg.target.add('button', [11,20,100,40], "select");

dlg.target.targetField = dlg.target.add('statictext', [11,50,100,155], String(myPath), {multiline:true});

dlg.target.targetSel.onClick = function () {

var target = Folder.selectDialog("select a target folder");

dlg.target.targetField.text = target.fsName

};

// ok- and cancel-buttons;

dlg.buildBtn = dlg.add('button', [220,460,410,475], 'OK', {name:'ok'});

dlg.cancelBtn = dlg.add('button', [21,460,210,475], 'Cancel', {name:'cancel'});

dlg.warning = dlg.add('statictext', [21,490,410,530], "be advised: existing files of the same name will be replaced without prompting", {multiline: true});

dlg.center();

So, specifically, I think it's these sections that need tinkering with. I can hard code a specific filepath (ie. /Users/Darryl/Google Drive/Jar pictures/Darryl's Images) into the code later on, and bypass the target-folder section entirely, but what I really need to do is get it to save the files in specific folder, depending on which label the top visible layer in the smart object, ie '/013U'.

013U would also need to be added as the suffix.

I've theorised that if I use my action to copy the top visible layer and paste it into the main PSD file as the top layer, I can maybe then use it's layer name in this script, but I've got no idea how I'd use it.

The final part of the puzzle then is for the OK button to click itself, because this is where the Action currently gets stuck. Even if I could automatically complete all the options, I'd still have to come back to my MacBook and click the OK button myself. I realise that is totally inefficient, and if I had the ability, I'd be far better off just bypassing the dialogue box altogether, and putting my desired settings straight into the code. I can only imagine that would involve rewriting this code pretty much from scratch though, which is way beyond me.

But I feel like I'm really close, and a few tweaks to the above code should do the trick.

Any ideas?

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 ,
Feb 03, 2019 Feb 03, 2019

Copy link to clipboard

Copied

I would like you to upload your mockup PSD file and Post a link to it so I can test with it.  Also look at  this append thread I started Today Long Winded Self Promoting  The scripts UI looks like this.

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 ,
Feb 04, 2019 Feb 04, 2019

Copy link to clipboard

Copied

That looks pretty cool. So you just put in the location of the .PSD you're working with, the location of where all the individual images are that you want to swap . out, and then the location of where you want to output them all to. That's so simple, it's brilliant!

This is a dropbox link to my .PSD template: Dropbox - SnT.psd

Let me know if that doesn't work.

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 ,
Feb 04, 2019 Feb 04, 2019

Copy link to clipboard

Copied

That link states your mockup is still uploading. Did it hang?

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 ,
Feb 04, 2019 Feb 04, 2019

Copy link to clipboard

Copied

I downloaded your PSD. It looks like you put all your eggs in one basket. While there may be some benefit doings so.  I do not like that you carried that down further to the extreme of all your assist not in one basket but into one egg.  IMO you would be better off resorting to the basket a folder where you can compartmentalize thing like jars, labels, Mockup Template, Output Mockup folders. You have all in one file a single point of failure. One egg to break.  All you labels are in a single smart layered object where a smart object layer is a single layer. To get at your labels you have to edit the object and change what is visible.  That e is a lot of editing even automated it will be a very time consuming.  Next all your mockup are in layer groups in the psd and there some or the jar layers do not fill the 2500x2500px canvas.  many of the jar layers you made into smart object layers. That just add overhead and increase file size. I do not believe you resize the jars layers. Having all mockups in one PSD file increases the of layers and make it harder to maintain, add complexity makes it harder to use  and add time consuming work. It is relatively easy to open a 2500x2500px 240Dpi Document drag one of your layer group mock to it duplicate the smart object layer move it above the group delete the smart filters  set it visibility off I  would also  set its  fill to zero  so you are sure it off even if someone turn on its viability. Or you could even just drag the one of the smart object layers out of the groul to be the top layer.  My Script requires the top layer to be a smart object layer.

I did create three mockup psd files for you first three groups and cleaned out the layers in the smart object .  I packaged it up for you to try it out download this Candy-Jars.zip

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 ,
Feb 06, 2019 Feb 06, 2019

Copy link to clipboard

Copied

This is amazing, thank you.

I knew that putting it all in one file would be inefficient and probably unsustainable, it already takes 10 minutes just to save the smart object and update all the various copies of the smart object, so when I add more and more labels, it's going to be ridiculous. This solves that problem.

So, just to be clear, the plan here is that I create Mockup Templates for all the different sweet types and sizes (so 84 currently) once I've done that set up, the rest can happen automatically by running the script.

Forgive my ignorance though, I can't seem to run the script to test it. I open it, press the play button, but then it highlights the row:

//@include "PCTpreferences.jsx"

I assume that means it's got stuck on that row, but I only discovered ExtendScriptToolkit a week or so ago, so I'm still finding my way around it. Normally I run the script from within Photoshop. But then it's just a comment, so I'm not sure why it would be effecting it at all.

PS . just tried running it through Photoshop, and it's telling me the file PCTPreferences.jsx doesn't exist.

One other thing, would it be possible to save them in folders based on the label, not the sweet type, doing it this way?

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 ,
Feb 06, 2019 Feb 06, 2019

Copy link to clipboard

Copied

I forgot to include that, I added two script to my Photo Collage Toolkit the one I package for you the can replace 1 smart object and one that can replace many I sarted the Scripts with a basic Collage dialog. That include the script for preferences. I'lll post the preferences script.  The Save as steps in the script should be easy for to change you would run for each mockup.  You could save all the output jpeg into a common folder.  Right now the file name are "Label Name Mockup Name"  Where mockup are for each of  you candies. So mockup name = Candy Name.  You could  make the file name "Mockup Name Label Name"  in a common output folder or made a the script create  sub folders for the mockup candy name. MockupName should be Candy Name.

Right now if you save all mockup output files into a common output folder and sort the folder on  file name the lists would be ordered "Label Sweet"  so  so bascly  sorted in Label order.

I tried to make the script a general solution.  You can separate be sweets by creating an output folder for each sweet mockup or have all  output  stored into a common folder  where file name sort will sort in label order. will sort labels together.

The label file name is part of the output file name.  You could save  all output to a common folder and add code into the script to create sub folder for the label name if if did not exist and  add the to  path the output files are saved to. currently the output name is constricted this way

"outputFile = outputFolder + "/" + theNewName +" " + templateName ; // Construct full output file path"

The  var theNewName is your label names the outputFolder the folder you set in the scripts dialog and templateName you seets mockup Name.

So you would check to see if a  folder named  theNewName exist if not create it. then change the output filename to include the theNewName folder to the path something like this:

"outputFile = outputFolder + "/" + theNewName + "/"  + theNewName +" " + templateName ; // Construct full output file path"

For all my Collage scripts. Free Photoshop Photo Collage Toolkit

Here is that missing script Preferences script only some  are referenced in the dialog  for mockups.  The Mockup script onle referebces two of the preferences. 

//* ==========================================================

// 2013  John J. McAssey (JJMack)

// ======================================================= */

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

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

// Image files and Template Alpha Channel "Image 1" should have the same orientation matching Aspect

// ratio is even better.  This script will try to transform the placed Images to match the Image 1 Alpha channel as

// best as it can and even try to handle orientation miss matches.

/* Help Category note tag menu can be used to place script in automate menu

<javascriptresource>

<about>$$$/JavaScripts/PCTpreferences/About=JJMack's Photo Collage Toolkit.^r^rCopyright 2013 Mouseprints.^r^rPreferences</about>

<category>JJMack's Collage Script</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();

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

//       SET-UP

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

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

///////////////////////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','Photo Collage Style 10','Photo Collage Style 11'];

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 templateFolder = "E:/Public Files/Pictures/Adobe Photoshop Templates/";

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

var imagePath = "~/Pictures/"; // Windows 7

//var imagePath = "E:/My Files/Pictures/";

// End hard coded variables

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

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

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

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 ,
Feb 08, 2019 Feb 08, 2019

Copy link to clipboard

Copied

I have updated my scripts for better performance dowload the latest version to solve a performance problem . Re: Long Winded Self Promoting

 

 

Free Photoshop Photo Collage Toolkit

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 ,
Feb 09, 2019 Feb 09, 2019

Copy link to clipboard

Copied

Nearly there then. I think I can work all that out. I doubt I can write the code to create folders automatically, but if everything is just ordered by label name, then I'll be able to find them in big chunks in the folder, and it won't be a big job to grab them and drag them into their appropriate folders.

But before I can play with that, I've tried to test the code as is, and produce the images that you have. It will run now, and doesn't get stuck at that line, but I'm still having a couple of issues:

1) when the dialogue box pops up, the first two buttons ('Select' and 'Browse') won't work, so I can't select the files I need. The second 'Browse' button does work though. I am able to just copy and paste the file paths from Finder though, so it's not a big problem.

2) If you can see in the screenprints below, something hasn't gone quite right. It's ended up saving the warped labels, but not with the sweets.

3) Will I have to run this script individually for each mockup I make. The dialogue box asks me to select a mock up file, rather than a folder, but there's going to be 84 of these (and another 15 varieties that I've got to add next week, so 45 more images), so that's still going to end up being a massive job. Would it be possible to select a folder with all the mockup PSDs in, then it runs them through one at a time?

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 ,
Feb 09, 2019 Feb 09, 2019

Copy link to clipboard

Copied

Edit the PCTpreferences jsx fule make sure to set default folders the are on youry machine for where Mockup templates and source image files are. My defaults are on my E: drive you may not have an E: drive

 

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

var templateFolder = "E:/Public Files/Pictures/Adobe Photoshop Templates/";

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

//var imagePath = "~/Pictures/"; // Windows 7

var imagePath = "E:/My Files/Pictures/";

 

The buttons in the dialog should work if you are on Windows and may also work if you use Mac OSX.  The Select button should open a file selection dialog that you can select your Mockup.psd file. The two browse buttons should open a folder selection dialog so select you input and output folders.

Capture.jpg

 

The Script is not coded to be a Photoshop plug-in therefore, you can not record using it in an action that will have the  mockup, input folder and output folders recorded into the Action script steps.  Even if it was a plug-in you  would need to record 84 script mockup steps.

 

To automate  all your mockup as a single job using file system structure I setup  for your Candy setup would requite changing the Script dialog and adding a little more code  That would not be hard to do.  The new interface would change the select mockup PSD to browse to your template folder to select the folder of templates.  In you case there is just one label input folder and one output mockup folder that would be used with all your mockup templates.  The script code would simply process the each mockup psd file using the existing code. An additional loop would need to be added. the process  all the psd in the folder. For your setup.  IMO its not a general solution it a solution for your custom setup.  If you want the solution you would need to learn a bit about coding a script to be able to modify the script dialog code and also add the process psd loop for your custom setup

 

 

I made a performance improvement in the scripts and repackage the candy-jar package.  COPY THE 3 SCRIPT TO YOUR  PHTOSHOP'S VERSION FOLDER PRESETS\SCRIPTS\

 

Candy-Jars.zip

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 ,
Feb 09, 2019 Feb 09, 2019

Copy link to clipboard

Copied

Besides editing the preferences to get the buttons working

 

I just change the scrip code around line 103  to look like this.

 

To remember folders you have selected templates from the new coud you coul dadd looks like this. I deleted some lines and added the two bold ones

 

dlg.msgPn0.btnSelect.onClick = function() {

var dir = Folder(dlg.msgPn0.etTemplateFile.text.substr(0, dlg.msgPn0.etTemplateFile.text.lastIndexOf("\\")+1));

if (!dir.exists) var dir =  Folder(templateFolder);

dlg.selTemplateFile = dir.openDlg(dlg.msgPn0.etTemplateFile.text , "Select:*.psd;*.psb");

if ( dlg.selTemplateFile != null ) {

        dlg.msgPn0.etTemplateFile.text = dlg.selTemplateFile.fsName;

    }

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 ,
Feb 10, 2019 Feb 10, 2019

Copy link to clipboard

Copied

Okay, so that will help it to remember the place I last selected a mock up template from, but not do anything regarding cycling through all the mock ups.

Looks like it might be back to the drawing board then, which might mean learning how to write the code to loop it

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