🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.photoshop.scripting
Article #2091

Re: Open dialog for text file

#2091
From: matthewrubino
Date: Wed, 23 Jun 2004 17:54
59 lines
2659 bytes
Okay, I wrote this completely in JavaScript. For anyone who would like to do something similar:

// Set input and output file paths as variables

var inPath = "S:/tmpPhotoRotate/tifin/";
var outPath = "S:/tmpPhotoRotate/tifout/";

// Open a dialog to prompt user to select a text file
  var openFile = File.openDialog ("Select a text file", "Text Files:*.txt");

// Open the text file and set the contents as
// array variables for input file name, output file name
// and rotation angle

if(openFile.open('r'))
    {
         // Turn the dialog display off
         app.displayDialogs = DialogModes.NO;

var aLine
      // While Loop
      while(aLine = openFile.readln())
       {
          // Create the array
          var elements = aLine.split(",");
          var eleInFileName = new File (inPath + elements[0]);
	 eleAngle = elements[2];
	 fltAngle = parseFloat(eleAngle); // Convert string to floating-point number
	 eleOutFileName = outPath + elements[1];

	 // Now open the image file
	 var docRef = app.open(eleInFileName);

	 // Now rotate the image on the canvas
	 docRef.rotateCanvas(fltAngle);

	 // Now save the rotated image as a TIFF
	 tifFile = new File(eleOutFileName);
	 tifSaveOptions = new TiffSaveOptions();
	 tifSaveOptions.alphaChannels = false;
	 tifSaveOptions.annotations = false;
	 tifSaveOptions.byteOrder = ByteOrder.IBM;
	 tifSaveOptions.embedColorProfile = true;
	 tifSaveOptions.imageCompression = TIFFEncoding.NONE;
	 //tifSaveOptions.jpegQuality = default;
	 //tifSaveOptions.layerCompression = default;
	 tifSaveOptions.layers = false;
	 tifSaveOptions.saveImagePyramid = false;
	 tifSaveOptions.spotColors = false;
	 tifSaveOptions.transparency = false;
	 app.activeDocument.saveAs(tifFile, tifSaveOptions, false,
	 Extension.LOWERCASE);

	 // Close the active document
	 app.activeDocument.close();

}
         openFile.close();
    }
Technical Details
Message-ID: <3bb4a774.9@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news2.euro.net!fi.sn.net!newsfeed2.fi.sn.net!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!webx
References: <3bb4a774.-1@webx.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f5839,9f372316bd6d2809
X-Google-Attributes: gidf5839,public
From: matthewrubino@adobeforums.com
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!news2.euro.net!fi.sn.net!newsfeed2.fi.sn.net!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.photoshop.scripting
Subject: Re: Open dialog for text file
Message-ID: <3bb4a774.9@webx.la2eafNXanI>
Date: Wed, 23 Jun 2004 10:54:49 -0700
References: <3bb4a774.-1@webx.la2eafNXanI>
Lines: 62
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit