Script EPS to TIFF


hello,

i know if use script batch processing lot of epss tiffs. every time open eps in ps, dialog box appears write down resolution. there way have batch take epss in given folder, open them once given resolution in rgb mode , save them tiffs (no layers, no compression) wouldn't have manually? every time tried record script this, got stuck on accepted setting of dialog box somehow wasn't recorded.. lot pavel

this checks eps using name, if other files mistakenly named ».eps« cause problems, , havent provided provision avoiding over-writting existing tiffs of same names, give try:
 

#target photoshop;

var dlg = new window('dialog', "save flattened tiffs of eps-files", [500,300,880,525]);

//filter checking if entry numeric, xbytor;

numberkeystrokefilter = function() {

   this.text = this.text.replace(",", ".");

   if (this.text.match(/[^\-\.\d]/)) {

      this.text = this.text.replace(/[^\-\.\d]/g, '');

   }

};

//create entry resolution;

dlg.msgpnl = dlg.add('panel', [25,100,355,170], 'resolution');

dlg.msgpnl.msget = dlg.msgpnl.add('edittext', [15,20,135,40], 150, {multiline:false});

dlg.msgpnl.msget.onchange = numberkeystrokefilter;

//create field folder-selection;

dlg.folderpnl = dlg.add('panel', [25,25,355,90]);

dlg.folderpnl.btn = dlg.folderpnl.add('button', [12,7,313,17], 'select folder process', {name:'remove'});

dlg.folderpnl.foldername = dlg.folderpnl.add('statictext', [12,35,313,55], "none selected", {multiline:false});

// select folder-function;

function folderselection (thefolder) {

   var thefolder = folder.selectdialog ("select folder");

   dlg.folderpnl.foldername.text = string(thefolder);

   };

dlg.folderpnl.btn.onclick = folderselection;

//fields ok , cancel;

dlg.buildbtn = dlg.add('button', [25,185,175,195], 'ok', {name:'ok'});

dlg.cancelbtn = dlg.add('button', [185,185,355,195], 'cancel', {name:'cancel'});

// show dialog;

var myreturn = dlg.show ();

//////////// operation //////////////////

if (myreturn == true && dlg.folderpnl.foldername.text != "none selected") {

// retrieve file-list , resolution;

var thefolder = dlg.folderpnl.foldername.text;

var thefilelist = folder(thefolder).getfiles();

var theresolution = dlg.msgpnl.msget .text;

// thing;

for (var m = 0; m < thefilelist.length; m++) {

   // getting name , location;

   var docname = thefilelist[m].name;

   var docpath = thefilelist[m].path;

   var basename = docname.match(/(.*)\.[^\.]+$/)[1];

   // open files names end on ».eps«;

   if (docname.slice(-4) == ".eps") {

      // =======================================================

      var idopn = charidtotypeid( "opn " );

         var desc1 = new actiondescriptor();

         var idnull = charidtotypeid( "null" );

         desc1.putpath( idnull, new file( thefilelist[m] ) );

         var idas = charidtotypeid( "as  " );

            var desc2 = new actiondescriptor();

            var idrslt = charidtotypeid( "rslt" );

            var idrsl = charidtotypeid( "#rsl" );

            desc2.putunitdouble( idrslt, idrsl, theresolution );

            var idanta = charidtotypeid( "anta" );

            desc2.putboolean( idanta, true );

         var idepsg = charidtotypeid( "epsg" );

         desc1.putobject( idas, idepsg, desc2 );

      executeaction( idopn, desc1, dialogmodes.no );

      // define copy:

      var thecopy = app.activedocument;

      // tiff options;

      tifopts = new tiffsaveoptions();

      tifopts.embedcolorprofile = true;

      tifopts.imagecompression = tiffencoding.tifflzw;

      tifopts.alphachannels = false;

      tifopts.byteorder = byteorder.macos;

      tifopts.layers = false;

      // make copy, flatten it, delete paths, set 8bit;

      thecopy.flatten();

      thecopy.bitsperchannel = bitsperchanneltype.eight;

      // save it;

      thecopy.saveas((new file(docpath+"/"+basename+".tif")),tifopts,true);

      thecopy.close(saveoptions.donotsavechanges);

      }

   else {}

   }

};

// use @ own risk;

if of spot unnecessary or stupid operations in script please let me know.


More discussions in Photoshop Scripting


adobe

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code