Skip to main content
Mac_06
Inspiring
January 3, 2013
Question

Scripted droplet not working [CS6]

  • January 3, 2013
  • 1 reply
  • 1079 views

Novice question in photoshop, I've a javascript which set the resoultion of image in selected folder through dialog box. Now my requirement is to create a droplet with this script.

Steps I've followd to create the action:
  1. Added new set in action palette.
  2. Added new action into.
  3. started recording.
  4. Select File-->Script-->Browse, and selected the path of script.
  5. Once the script finish the task, stops recording.

Now If I run this action it works as expected. let's created droplet now.

Steps I've followd to create the droplet:

  1. Select File-->Automate-->Create Droplet.
  2. Choose the destination
  3. Choose the appropriate Set and action.
  4. Uncheck all the check box otions since all the need to just trigger the script.
  5. click OK.

Now If I run the droplet it should execute the script, but it won't do any action

Any help would be greatly appriciated.

Thanks

Mac

This topic has been closed for replies.

1 reply

c.pfaffenbichler
Community Expert
Community Expert
January 3, 2013

Please post the Script.

If the Script offers Folder-selection then what good would a droplet be?

Mac_06
Mac_06Author
Inspiring
January 4, 2013

Thanks for reply, The only thing that can not be achieved by droplet is to close Photoshop after performing the action on each file in folder.

#target photoshop

var startRulerUnits = app.preferences.rulerUnits

var startTypeUnits = app.preferences.typeUnits

var startDisplayDialogs = app.displayDialogs

// Set Adobe Photoshop CS3 to use pixels and display no dialogs

app.displayDialogs = DialogModes.NO

app.preferences.rulerUnits = Units.PIXELS

app.preferences.typeUnits = TypeUnits.PIXELS

var inputFolder = Folder.selectDialog("Select a folder to tag");

if(inputFolder != null)

{

    if((inputFolder.fsName.split("/").pop()).toLowerCase() == "jpeg")

    {

        var outputFolderPath = inputFolder.fsName.slice(0, inputFolder.fsName.lastIndexOf ("/")),

        JPEGLFolder = new Folder(outputFolderPath+"/JPEGL"), 

        JPEGHFolder = new Folder(outputFolderPath+"/JPEGH");

        if(!Folder(JPEGLFolder).exists)

        {

            JPEGLFolder.create();

        }

        if(!Folder(JPEGHFolder).exists)

        {

            JPEGHFolder.create();

        }

        if (inputFolder != null ) {

          

            getSubFolders(inputFolder);

        }

    }

    else

    {

        alert ("You should select only JPEG folder for this action")

     }

}

    resetSettings ();

    $.sleep (3000)

    var idquit = charIDToTypeID( "quit" );

    executeAction( idquit, undefined, DialogModes.ALL );

function resizeImageByValue(imageFile, resizeValue, destinationFolder)

{

    try

    {

        var docRef = open(imageFile),

        irw=docRef.width,

        irh=docRef.height;

        if(irw>irh)

        {

            docRef.resizeImage(resizeValue,null)

        }

        else if(irw<irh)

        {

            docRef.resizeImage(null,resizeValue)

        }

        else if(irw==irh)

        {

            docRef.resizeImage(resizeValue,resizeValue);

        }

        var jpegOptions = new JPEGSaveOptions()

        docRef.SaveDocumentType=SaveDocumentType.JPEG

        //jpegOptions.imageCompression=TIFFEncoding.JPEG

        jpegOptions.quality = 11

        jpegOptions.formatOptions=FormatOptions.STANDARDBASELINE

        docRef.bitsPerChannel = BitsPerChannelType.EIGHT

        // save and close

        docRef.saveAs(new File(destinationFolder +"/"+ imageFile.name), jpegOptions);

        docRef.close(SaveOptions.SAVECHANGES);       

    }

    catch(e)

    {

            alert ("Error: "+ e);

            resetSettings()

            throw e;

     }

}

function resetSettings()

{

    app.preferences.rulerUnits = startRulerUnits;

    app.preferences.typeUnits = startTypeUnits;

    app.displayDialogs = startDisplayDialogs;

}

function getSubFolders(theFolder) {

    try{

        var jpegLDepoyFolder, jpegHDeployFolder,

         myFileList = theFolder.getFiles();

        if(myFileList != null)

        {

             for (var i = 0; i < myFileList.length; i++) {

                  var my_File = myFileList;

                  if (my_File instanceof Folder){

                       getSubFolders(my_File);

                  }

                  else if (my_File instanceof File && my_File.name.match(/\.jpg$/i)) {

                      var substr = my_File.parent.fsName.split("/JPEG")[1];                     

                      jpegLDepoyFolder = new Folder(JPEGLFolder.fsName+substr);

                      jpegHDeployFolder = new Folder(JPEGHFolder.fsName+substr);

                      if(!Folder(jpegLDepoyFolder).exists)

                    {

                        jpegLDepoyFolder.create();

                    }

                   

                    if(!Folder(jpegHDeployFolder).exists)

                    {

                        jpegHDeployFolder.create();

                    }

                       resizeImageByValue(my_File, 180, jpegLDepoyFolder)

                       resizeImageByValue(my_File, 360, jpegHDeployFolder)

                  }

             }

         }

    }

catch(e)

{

        alert ("Error: Can not create sub folders: " + e);

        resetSettings();     

    }

}

If there could be any way to close photoshop once the action performed on each file in folder then diffinetly, I could skip this script but do it through droplet itself?

Thnaks

Mac