Highlighted

Looking for help creating a dialogue box where I can choose a png file from my desktop

New Here ,
Sep 18, 2020

Copy link to clipboard

Copied

Hello everyone. 

I hope I can make some sence of this. 

I have no scripting knowledge and wondered if anyone knew about plug ins or point me in the right direction. 

 

I have an action that needs a template ( a png file) dropped in at the end. 
So far my options are to have the same action for each template, meaning i have about 6 buttons in my action window. 

use patterns, which I dont want to do, 

or, at the point in the action that places my png mage, i manually choose the png file in a "open in finder window"

 

Im using the latter but I was hoping I could do all of this in photoshop, maybe with a dialogue box that lets me choose my template from a dropdown menu. a bit like the pattern dialogue box, but NOT using a pattern. 

 

Any help would be amazing. 

Thanks Friends

TOPICS
Actions and scripting, How to, Mac

Views

58

Likes

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

Looking for help creating a dialogue box where I can choose a png file from my desktop

New Here ,
Sep 18, 2020

Copy link to clipboard

Copied

Hello everyone. 

I hope I can make some sence of this. 

I have no scripting knowledge and wondered if anyone knew about plug ins or point me in the right direction. 

 

I have an action that needs a template ( a png file) dropped in at the end. 
So far my options are to have the same action for each template, meaning i have about 6 buttons in my action window. 

use patterns, which I dont want to do, 

or, at the point in the action that places my png mage, i manually choose the png file in a "open in finder window"

 

Im using the latter but I was hoping I could do all of this in photoshop, maybe with a dialogue box that lets me choose my template from a dropdown menu. a bit like the pattern dialogue box, but NOT using a pattern. 

 

Any help would be amazing. 

Thanks Friends

TOPICS
Actions and scripting, How to, Mac

Views

59

Likes

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
Sep 18, 2020 0
LEGEND ,
Sep 18, 2020

Copy link to clipboard

Copied

I don’ tthink a dropdownlist is a good idea, though … 

// 2020, use it at your own risk;
if (app.documents.length > 0) {
var theString = "~/Desktop";
var theFile = selectAPng (theString);
if (theFile != null) {placeScaleRotateFile(theFile, 0, 0, 100, 100, 0, false)};
};
////// filter files  for mac //////
function getFiles (theFile) {
    if (theFile.name.match(/\.(png|PNG)$/i)) {
        return true
        };
    };
////// place //////
function placeScaleRotateFile (file, xOffset, yOffset, theXScale, theYScale, theAngle, linked) {
    // =======================================================
    var idPxl = charIDToTypeID( "#Pxl" );
    var idPrc = charIDToTypeID( "#Prc" );
    var idPlc = charIDToTypeID( "Plc " );
        var desc5 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
        desc5.putPath( idnull, new File( file ) );
        var idFTcs = charIDToTypeID( "FTcs" );
        var idQCSt = charIDToTypeID( "QCSt" );
        var idQcsa = charIDToTypeID( "Qcsa" );
        desc5.putEnumerated( idFTcs, idQCSt, idQcsa );
        var idOfst = charIDToTypeID( "Ofst" );
            var desc6 = new ActionDescriptor();
            var idHrzn = charIDToTypeID( "Hrzn" );
            desc6.putUnitDouble( idHrzn, idPxl, xOffset );
            var idVrtc = charIDToTypeID( "Vrtc" );
            desc6.putUnitDouble( idVrtc, idPxl, yOffset );
        var idOfst = charIDToTypeID( "Ofst" );
        desc5.putObject( idOfst, idOfst, desc6 );
        var idWdth = charIDToTypeID( "Wdth" );
        desc5.putUnitDouble( idWdth, idPrc, theYScale );
        var idHght = charIDToTypeID( "Hght" );
        desc5.putUnitDouble( idHght, idPrc, theXScale );
        var idAngl = charIDToTypeID( "Angl" );
        var idAng = charIDToTypeID( "#Ang" );
        desc5.putUnitDouble( idAngl, idAng,theAngle );	
    if (linked == true) {
        var idLnkd = charIDToTypeID( "Lnkd" );
        desc5.putBoolean( idLnkd, true );
        };
    executeAction( idPlc, desc5, DialogModes.NO );
    // get layerid;
    var ref = new ActionReference();
    ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("layerID"));
    ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
    var layerDesc = executeActionGet(ref);
    var layerID = layerDesc.getInteger (stringIDToTypeID ("layerID"));
    // =======================================================
    return [app.activeDocument.activeLayer, layerID];
    };
////// select dialog //////
function selectAPng (thePath) {
    var theFiles = new Folder(thePath).getFiles(getFiles);
    var theList = new Array;
    for (var m = 0; m < theFiles.length; m++) {
        theList.push(theFiles[m].name)
        };
    var dlg = new Window('dialog', "sessions", [500,300,1020,410]);	
    dlg.pathSel = dlg.add('dropdownlist', [12,13,506,35], (theList));
    dlg.pathSel.selection = dlg.pathSel[0];
    dlg.cancelBtn = dlg.add('button', [13,72,258,82], 'Cancel', {name:'cancel'});
    dlg.buildBtn = dlg.add('button', [268,72,513,82], 'OK', {name:'ok'});
    dlg.pathSel.active = true;
////////////////////////////////////
    dlg.center();
    var myReturn = dlg.show ();
    if (myReturn == true) {return theFiles[dlg.pathSel.selection.index]} 
    else {return null}
    };

 

Likes

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
Reply
Loading...
Sep 18, 2020 1
JJMack LATEST
Most Valuable Participant ,
Sep 18, 2020

Copy link to clipboard

Copied

Around 2005  on Windows I was crafting Actions to populate templates PSD files.   I had quite a bit on knowledge about crafting actions and knew how to use Photoshop well.  I would not say I had a hard time crafting Interactive action to populate photo collage templates.  However If I want to populate 5 images a needed to create an action toe populate 5 images.  If I wanted to populated  4 images I need and for  a 4 image template and so on. It was a PIA and and I could mot create actions the automatically populated images for batch does not support feeding images to  an action  processing a template and action can not use logic to know how many Image deed to be populated into a template.

 

The thing is to automatically population a templates you need to be able to use some logic in the processing and the a template to be populated automatically there needs to be some logical way that they can be populated.  Being a retired Programmer I knew Actions could not Hack it.     

 

There are two requirement.   Programming support and good templates designs.  There are may ways you can created templates. However for automatic population the templates need to have a document structure that was designed to be populated via an automated process. They have to conform to some rules.  Template PSD files commonly use Smart object Layer that have their content replaced during the populating process.  While the sounds quite easy it actually is and is not.  If you have replacement objects that are exactly the same size as the objects in the template it is easy you simply use "Replace Content".  If  you do not have replacement objects that are the correct size you need to reprocess all replacement objects before you use "Replace Content" or you need to Edit the existing template Object and fit the replacement to the object.   While that sounds easy it not.  Not all object are Photoshop object. Some Objects can be Camera RAW file and other Vector Image Files.  A photoshop script would lose control of the edit Process for ACR or AI will be used to open and edit the objects.  If the Object is a Photoshop the Photoshop script can edit the one and fit in the replacement file.  If the replacement file aspect ration is not the same as the object the script need ways to fit the replacement in.

 

So I knew using Smart Object Layers in a template would be above my ability.  For I did not know anything about JavaScript or Photoshop Scripting.  However, I had a programming background and looking at some Adobe Photoshop Scripts in Photoshop's scripts folder I knew I would be able toe hack at Photoshop scripting. 

 

So I design a simple template design that did not use smart object layers for images.  In the template.  In fact no image layer are required. the only actual layer that is required is there must be a background layer it content can be anything. What is required are Alpha Channels that Map the template images location, size and shape. The same design I was using in may actions.  However that design does not support image rotation, perspective and warping.  Shape can make it look like there has been perspective added.  After a template is populated you can manually add the rotation and warping to the placed in images. 

 

In 2019 R-bin post some script code that retrieve the type of object a smart object layer has.   I now had a way to handle templates  with smart object layer the have rotation warning etc.    They will not be able to edit in replacement  for vector object but my script will not loose control if a template has vector smart object.  I do not install AI and have no intention to. So I do not support vector smart objects.

 

In 2019 I add a support for simple to populate mockup template design I often saw on the Web.   Most templates that exist can be modified easily to comply with this design.  Though RAW and Vector Object cans not be edited,  The object in the Templates can easily be replaced withe same size Photoshop object like a PSD object.

 

If you read this far you mat want to look at the scripts in package the should work on a mac.Free Photoshop Photo Collage and Mockupo Toolkit 

 

JJMack

Likes

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
Reply
Loading...
Sep 18, 2020 1