Skip to main content
Participating Frequently
September 25, 2018
Question

Open folder image file in photoshop using java script with layer wise.

  • September 25, 2018
  • 4 replies
  • 5187 views

Hi to all,

Dear team,

I am Rakesh from India i have faced an issue with my script, I just want to open a folder image in photoshop with layer wise.

It means suppose i have 2 image file in a folder named "ABC_client.tiff" & "ABC_final.tiff", I want to open both file in single photoshop frame with layered.

I have code a script but it open both file seperately.

So we need a support or help, please update or edit my script.

var dir = Folder('/Users/user/Desktop'); 

var files = dir.openDlg('This is always the same folder?','',true);

if( files !=null ){

for(var f = 0;f< files.length;f++){

open(files);

}

}

Thanks

Rakesh

This topic has been closed for replies.

4 replies

JJMack
Community Expert
Community Expert
September 25, 2018

r-bin code open the first flattens it  and places the other image in as layers and rasterize the smart object layers,  If you files have different sized any image larger then the first one may be resized sizes to fit within the first document canvas size or may be larger that the canvas size.  Depends on your Photoshop preference for place handling.

JJMack
Legend
September 25, 2018

May be?

var dir = Folder('/Users/user/Desktop');

var files = dir.openDlg('This is always the same folder?','',true);

if (files != null)

    {

    for (var f = 0; f< files.length; f++)

        {

        if (!f)

            {

            open(files);

            activeDocument.flatten();

            }

        else

            {

            var d = new ActionDescriptor();

            d.putPath(stringIDToTypeID("null"), files);

            d.putEnumerated(stringIDToTypeID("freeTransformCenterState"), stringIDToTypeID("quadCenterState"), stringIDToTypeID("QCSAverage"));

            executeAction(stringIDToTypeID("placeEvent"), d, DialogModes.NO);

            activeDocument.activeLayer.rasterize(RasterizeType.ENTIRELAYER);

            }

        activeDocument.activeLayer.name = File.decode(files.name);

        }

    }

Participating Frequently
September 26, 2018

Hi geppettol66959005,

Thanks for support, Your script is working fine but when i run this, it will open a folder image file in described format, which is mention in script, but i want open image file without mention the size in script..

When i open spread file it is open in half view.

but when i open single page file it is open full but extra transparent margin is there.

If is it possible in script to open document in his own size perfeactly view in Photoshop. (Either it is Page or Spread)

Please do needfull support.

Document will automatically open in his own size without mentioning in script.

Thanks

Rakesh

Geppetto Luis
Legend
September 26, 2018

Change line 78

from so

var newDoc = app.documents.add (2400, 2400, 200, "Doc temp", NewDocumentMode.RGB, DocumentFill.TRANSPARENT, 1);

to

var newDoc = app.documents.add (10000, 1000, 300, "Doc temp", NewDocumentMode.RGB, DocumentFill.TRANSPARENT, 1);

change line 100

from so

app.activeDocument.trim (TrimType.TRANSPARENT, false, false, false, false);

to

app.activeDocument.trim (TrimType.TRANSPARENT, true, true, true, true);

See if it's okay for your purpose

Stephen Marsh
Community Expert
Community Expert
September 25, 2018

File > Scripts > Load Files into Stack

Participating Frequently
September 25, 2018

Thanks for reply,

I know about this step but there have manual intervention like select file or folder then check open align option then press open... and I want to create javascript to for plugin design in configurator so we just click plugin button and folder file is automatic open in photoshop with layered.

This is requirement that's why I need a help.

JJMack
Community Expert
Community Expert
September 25, 2018

If you know what you want to do what is stopping you from coding the script? You can read the code in load files into stack and see how it process a folder to get all the filed in it,  read the code to stack a list of  files

JJMack
September 25, 2018
Participating Frequently
September 25, 2018

I have search so many JavaScript function in Photoshop Scripting but can't get exact result which i want..

open all folder image in layer wise in photoshop...

If you have you can change or edit my script please do need full.

Thnaks

JJMack
Community Expert
Community Expert
September 25, 2018

You need to open the first file  then place in then other files or Create a new document open the image files one at a time size them and past them into the document you created where you want the  images and close the image document without saving.

http://www.mouseprints.net/old/dpr/PasteImageRoll.jsx

JJMack