3 Replies Latest reply on May 24, 2010 11:06 AM by Michael L Hale

    NewDocumentMode Question

    PhotoNewbieNoob

       

      I have two images that I am receiving from another program and I want to merge them into one image with each having 50% opacity.  I'm having trouble opening then in the proper way.  The file extension is "att" which boils down to a 16-bit grayscale, IBM-ordered data.

       

      Here is my script minus the setup to preserve and restore the Photoshop environment to its prescript settings.

       

      The input data is stored in the following manor by the previous steps/programs

      ProjectName/PhotoSession1/View0, View1, ... ViewN

      ProjectName/PhotoSession2/View0, View1, ... ViewN

      where the object can be shot at any number of angles (views) in two separate photo sessions.  ViewN in each PhotoSession folder is the same angle, so the images should be the same except for and changes in the cameras settings.

       

      1 var docRef = new Array();

      2 var fileList = new Array();

      3 var docRef = new Array();

      4 var docRef = new Array();

      5

      6
      7 // Settings for the user to change

      8 var SEARCH_MASK = "*.att";

      9 var saveLocation = "\\DocAndSetting\\user\\whatever\\";

      10 var width = 600;

      11 var height = 400;

      12 var fileName = "MergedImage ";

      13 var sessions = 2;

      14 var weighting = [50.0, 50.0];

      15

      16 try {

      17 for( var a = 0; a < sessions; a++ ) {

      18     inputFolders[a] = Folder.selectDialog("Select folder " + (a+1) + " to process.");

      19

      20     fileList[a] = InputFolders[a].getFiles(SEARCH_MASK);

      21     if( fileList[a] == null )

      22      throw X_NOINPUT;  // No images

      23     }

      24   }

      25

      26   for( var b = 0; b < sessions; b++ ) {

      27    var merged = document.add( width, height, fileName+a, NewDocumentMode.GRAYSCALE, DocumentFill.WHITE);

      28

      29   for( var c = 0; c < sessions; c++ ) {

      30     var rawFile = new File( Folder.desktop + ‘View0’); // Update to read diff images

      31     var layer = docRef[c].activeLayer;

      32    layer.duplicate(merged, ElementPlacement.PLACEATBEGINNING);

      33     docRef[c].close(Saveoptions.DONOTSAVECHANGES);

      34     merged.layers[0].opacity = weighting[c];

      35   }  // End for c

      36 }  // End for b

      37

      38 } catch( exception ) {

      39 Alert( “** In catch block ** “ + exception );

      40 }

       

       

      I looked in the CS3 scripting guide and I see NewDocumentMode has a RGB (16-bit color) and GRAYSCALE (8-bit grayscale) option.  The RGB option triples the width of my image making my image file size much larger.  I assume this is because of the three channels and I only provide it one.  The GRAYSCALE option does the opposite and shrinks my image size because it expects 8-bit data and drops 1/2 of what I provide.

       

      The program that reads in my merged images (called finalPrep) expects the size to be the same as it was before my program merged the images and finalPrep can't be easily modified to accept other size images. Is there a way to open a 16-bit grayscale image and merge into that?  Or is there a way to modify my script, so I can open one of the images and merge into that image? I tried modifying it to the following.

       

      27  var merged = new File( Folder.desktop + ‘View0’);

      28

      29   for( var c = 1; c < sessions; c++ ) {

      30     var rawFile = new File( Folder.desktop + ‘View0’); // Update to read diff images

      31     var layer = docRef[c].activeLayer;

      32    layer.duplicate(merged, ElementPlacement.PLACEATBEGINNING);

      33     docRef[c].close(Saveoptions.DONOTSAVECHANGES);

      34     merged.layers[0].opacity = weighting[c];

      35   }  // End for c

      36 }  // End for b

       

      But I got an error on line 32 (Argument 1, illegal)

       

      Thanks for any help you can give everyone!