Need help editing strings from document info


i trying create string based on info active doument saved tab delimited text use in spreadsheets.

 

i new scripting have been able info photoshop need process of it.

 

here info want in order want: filename, file size ( either working size or actual), pixel width, pixel height, inches width, inches height, image resolution, color mode.

 

example: coolpicture_lyrd.psd     5.3 mb     3810    3810    5     5     762     rgb

 

here info have gotten back:

 

coolpicture_lyrd.psd3810 px3810 px5 px5 px762 dpidocumentmode.rgb

 

i need make these changes:

  1. add document size
  2. trim px form strings or convert "px" in inches string "in"
  3. short numbers 6 characters ( number 5.33333333333333 px)
  4. trim thedocumentmode. color mode info

 

i have tried using substrings gets error functions

i have tried tostring( ) , setting range no luck.

 

any appreciated. looking.

 

here script far

 

//get info document need excel sheet var imageheightpixels = activedocument.height var imagewidthpixels = activedocument.width var fileresolution = activedocument.resolution var imagemode = activedocument.mode // size in inches pixel based measurement var imageheightinches = imageheightpixels / fileresolution var imagewidthinches = imagewidthpixels  / fileresolution   var imagename = activedocument.name.tostring() var imagedimensions = new file ("~/desktop/file info report.txt")     app.preferences.rulerunits = units.pixels  imagedimensions.open('a');   imagedimensions.write(imagename + "\t" + imageheightpixels + "\t" + imagewidthpixels + "\t" + imagewidthinches + "\t" + imageheightinches + "\t" + fileresolution + " dpi" + "\t" + imagemode + "\n");   activedocument.close(saveoptions.donotsavechanges)      imagedimensions.close();  

there go buddy:

 

var doc = app.activedocument; var currentunits = app.preferences.rulerunits;  app.preferences.rulerunits = units.pixels;  var filename = doc.name; var filesize = (file(doc.fullname).length / (1024 * 1024)).tofixed(2); var filewidthpx   = doc.width.value; var fileheightpx = doc.height.value; var fileresolution = doc.resolution; var filewidthinch = (filewidthpx  / fileresolution).tofixed(6); var fileheigthinch = (fileheightpx / fileresolution).tofixed(6); var colormode = doc.mode.tostring().split(".")[1];  app.preferences.rulerunits = currentunits;  var outputstring = filename + "\t" +    filesize + " mb\t" +    filewidthpx + "\t" +    fileheightpx + "\t" +    filewidthinch + "\t" +    fileheigthinch + "\t" +    fileresolution + " dpi\t" +    colormode + "\n";    var logfile = new file ("~/desktop/file info report.txt");   logfile.open('a');       logfile.write(outputstring);   logfile.close();  doc.close(saveoptions.donotsavechanges); 


More discussions in Photoshop Scripting


adobe

Comments

Popular posts from this blog

Illustrator CS6 Ocurrío un error E/S en el archivo.

Why is os_ViewContainer running?

Animate - problem with duplicating scripts after loop