skip to Main Content

I have a script in Photoshop, but I need one thing. I want to get (parse) the width and height data from a file. How can I do that? File can be txt or xml. I use ExtendScript Toolkit from Photoshop.

if ( activeDocument.width != 100 || activeDocument.height != 100 ) {
    displayDialogs = DialogModes.ALL;
    activeDocument.resizeImage( 100, 100, 72, ResampleMethod.BICUBIC );
    displayDialogs = DialogModes.NO;
}

Thanks for help

2

Answers


  1. Chosen as BEST ANSWER

    I simply want get 2 variables from a file and before code i need var width=(first data in file) and var height=(second data). When i get this i can modifity script to look like:

    if ( activeDocument.width != width || activeDocument.height != height ) {
        displayDialogs = DialogModes.ALL;
        activeDocument.resizeImage( width, height, 72, ResampleMethod.BICUBIC );
        displayDialogs = DialogModes.NO;
    }
    

    In your code i have all from that file in one variable "words"


  2. I’m still a bit confused as what you want.
    However, you can load in a text file as data into Photoshop with this:

    function readIt(fName)
    {
        var theFile = new File(fName);
    
        //read in file 
        var words = [];
    
        var textFile = new File(theFile);
        textFile.open('r');
    
        while(!textFile.eof)
        {
          var line = textFile.readln();
          if (line != null && line.length >0)
          {
            words.append(line);
          }
    
        }
        textFile.close();
    
        // return array
        return words;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search