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

Designing a work script

New Here ,
Jan 02, 2018 Jan 02, 2018

Hello everyone and best wishes for 2018.

Sorry in advance for my english

I'm starting to try to make photoshop scripts via extendscript. Something that is not simple, the more I progress and the more I encounter difficulties.

Here is my project very precisely:

1. Select the files to be processed

2. Check the files in the first folder

3. Relative to the file name, open, resize, and move to a base image at a specific location

4. Once all the images in the folder have been processed, save a jpeg containing the folder name.

5. Move to the next folder.

I started writing and collecting bits of code, but unfortunately I still can not get them to work properly. In my example, the script opens all the images in the folder, which I do not want. Then, I have not yet managed to write / find the ability to move a layer to my base image and especially to position this layer with XY coordinates.

What I want in the ideal is: check the name, open the image, resize it, copy it on the base image and position it on it. Then do the same with the next picture and so on. Then save a jpeg of this timeline with the name of the source folder and move to the next folder. A bit like a batch treatment.

I do not ask you to make the code (although it will help me a lot), but what interests me the most are the explanations in order to understand and become autonomous for the future.

I am copying the code I currently have and thank you in advance for all the advice and help I can get from you.

#target photoshop

// prefs unites

app.preferences.rulerUnits = Units.PIXELS;

// mode couleur

function ChangeMode () {

  doc.changeMode(ChangeMode.RGB);

};

// 4 paramètres : document, largeur hauteur et résolution que tu passe en papramètre en appelent la fonction

function Resize (_doc, _width, _height, _resolution) {

  _doc.resizeImage (_width, _height, _resolution);

};

//ouvre toutes images

function open360() {

     var filesOpened = 0;

        var fileList = inputFolder.getFiles();

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

        open( fileList );

        filesOpened++;

  }

  

}

open360();

var doc = app.activeDocument;

var filesOpened = app.activeFiles;

var fileList = inputFolder.getFiles();

//check liste de fichiers et travail dessus

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

        open(fileList);

        filesOpened++;

        if(fileList.name.indexOf("_Z1") != -1){ //si contient "z1"

            Resize(doc, 1630, 1630, 72);

        } else if(fileList.name.indexOf("_P") != -1){ //si contient "p"

            Resize(doc, 688, 688, 72);

            } else if(fileList.name.indexOf("_D1") != -1){ //si contient "d1"

            Resize(doc, 688, 688, 72);

            } else if(fileList.name.indexOf("_D2") != -1){ //si contient "d2"

            Resize(doc, 345, 345, 72);

            } else if(fileList.name.indexOf("_D3") != -1){ //si contient "d3"

            Resize(doc, 345, 345, 72);

            } else if(fileList.name.indexOf("_D4") != -1){ //si contient "d4"

            Resize(doc, 345, 345, 72);

            } else if(fileList.name.indexOf("_D5") != -1){ //si contient "d5"

            Resize(doc, 345, 345, 72);

            } else if(fileList.name.indexOf("_D6") != -1){ //si contient "d6"

            Resize(doc, 345, 345, 72);

            } else if(fileList.name.indexOf("_DIV") != -1){ //si contient "div"

            Resize(doc, 345, 345, 72);

            } else if(fileList.name.indexOf("_C1") != -1){ //si contient "c1"

            Resize(doc, 345, 345, 72);

            } else if(fileList.name.indexOf("_C2") != -1){ //si contient "c2"

            Resize(doc, 345, 345, 72);

            } else if(fileList.name.indexOf("_C3") != -1){ //si contient "c3"

            Resize(doc, 345, 345, 72);

            } else if(fileList.name.indexOf("_C4") != -1){ //si contient "c4"

            Resize(doc, 345, 345, 72);

            } else if(fileList.name.indexOf("_C5") != -1){ //si contient "c5"

            Resize(doc, 345, 345, 72);

            } else if(fileList.name.indexOf("_C6") != -1){ //si contient "c6"

            Resize(doc, 345, 345, 72);

        } else { //everything else

            //third set of actions

        }

}

//ouvrir Mep Vierge

function OpenMepVierge ()

   

    var MepVierge = app.open(File("/Applications/Adobe Photoshop CS6/Presets/Scripts/MEP.jpg"));

}

OpenMepVierge ()

  

TOPICS
Actions and scripting
479
Translate
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 02, 2018 Jan 02, 2018
  1. By "and move to a base image at a specific location" you mean processed .jpg image that was opened from one of your folders has to be placed inside of other file? If so, any next file of your folders has to be placed in the same 'base image'?
  2. Is it the path to that 'base image': "/Applications/Adobe Photoshop CS6/Presets/Scripts/MEP.jpg"? If yes, should be all other images placed in this 'base image' saved with .psd format?
  3. You're using "move" word (not copy/save), so do you mean that each opened .jpg file from one of your selected folders has not to be overwritten, but saved to other file as its another layer?
  4. Another question is where exacly your processed image(s) has to be placed in a 'base image', for example in the center that each another processed image will be covering as new layer previous placed (layer) image?
  5. If it is like you imagine it what has to happen with original opened .jpg file. Does it has to remain in its original folder or (if you say "move") deleted from that folder?
  6. If you want all original files be removed from their folders after you process them is your point all fodlers those files were gathered in to be deleted as well?
  7. If a folder that conteined removed files will be removed do you want .jpg image be created instead of equivalent folder or if a folder has not to be removed then next to it, or maybe inside that folder?
  8. Say more precisely what has to be "position this layer with XY coordinates". As I asked earlier, do you want each next .jpg be on top of previous or maybe next to each other like on chessboard? (What's w&h and res. of your base image?)
  9. Do all your jpgs with a name from _D3 to _C6 have to be resized to 345 width & 345 height or you simply copied it (to save your time)?
  10. What is exact name of your .jpg files. Do their names contain something more than for ex. _D3.jpg like Myfile_D3.jpg or _D3_somefile.jpg?
Translate
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 03, 2018 Jan 03, 2018
LATEST

Hi Kukurykus and thank.

to answer you :

1. Yes indeed, there can be up to 15 images in a folder to move on the same jpeg. But there can also be only 2 or 3.

2. Yes this is the way to find the basic image to use. I do not have the utility to keep the psd. I prefer to save the jpeg on the desktop for example.

3. We could say copy / paste, in French "moving" is used for this kind of manipulation.

4. Each image following its name will have a precise positioning, for example _Z1 should come to the center at the top of the page, _D2 at the bottom right, _C6 at the top left.

5. No, we open it, place the layers on it, record a jpeg on the desktop, but most importantly we do not record the basic jpeg that should be used for each.

6. No need to erase them

7. The new jpeg create can be found next to its folder or in another folder dedicated on the desktop. This remains a not very complex step for me to create.

8. Therefore, each image will have a definite place. the base is 2400px x 2400px. The _Z1 will be 1630px x 1630px and come in the center up. _D2 will do 345px x 345px and come down right with a small margin ...

9. They all do 345px x 345px except _Z1 _D1 and _P which will be at 1630px and 688px

10. Yes quite. Take for example the folder 145698. The images inside will be named 145698_Z1.jpg, 145698_C1.jpg, 145698_D1.jpg .....
The final image, should have as name 145698_mep.jpg.
Then we renew the process on the following folder and so on ....

Thank you in advance for your interest in my problem.
have a good day

Any images for exemple :

546693470_MEP.jpg546693470_MEP.jpg141607_mep.jpg

Translate
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