Resize script help

admirable

Suspended / Banned
Messages
11,612
Name
Jim
Edit My Images
Yes
I have tried to alter the exif data script that was posted on here some time ago so that it only resizes to 800 max width without the exif data and border but I'm having no luck. :bang:

Could some kind soul show me how, or do it for me or, point me to a scipt tutorial?

cheers
 
have a look here
 
Hi

This resizes to a 1000px take a look I just upped all the size numbers in // Prep the image bit by 200px 800 became 1000 762 to 962 and so on I also changed the (C) to a copyright symbol in the original script, HTH Dave

// Add Image Data around the border of the image
// Photoshop CS Script


// First thing is to set up what setting will be used in the rest of the script
// but save them so they can be reset to what they were before this script is ran.
displayDialogs = DialogModes.NO;
var defaultRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;



// Define Colors
var black = new SolidColor();
black.rgb.red = black.rgb.green = black.rgb.blue = 0;
var white = new SolidColor();
white.rgb.red = white.rgb.green = white.rgb.blue = 255;
var BoarderColor = white;
var red = new SolidColor();
red.rgb.red = 255;
red.rgb.green = red.rgb.blue = 0;
var StrokeColor = black;

var AD = app.activeDocument;

PrepImage();
AuthorText();
ImageDataText(getExifData());

AD.flatten();

// END:Below are functions


// Prep the image
// 1. If image is greater then 1000 pixels, then size it down
// 2. Set to 72dpi
// 3. Create white poloriod type boarder around image for text
function PrepImage() **

// Set resolution to 72dpi for monitor viewing
var resRatio = AD.resolution/72;

if(resRatio!=1)**
AD.resizeImage(AD.width.value,AD.height.value,72);
**

// checking if landscape and if so, set width to 1000 and height to proportionate value
if(AD.width.value>AD.height.value)**
if(AD.width.value>1000)**
AD.resizeImage(965, AD.height.value/AD.width.value*962);
**
**
// checking if portrait and if so, set width to 1000 and height to proportionate value
if(AD.height.value>AD.width.value)**
if(AD.height.value>1000)**
AD.resizeImage(AD.width.value/AD.height.value*962,962);
**
**

// Create stoke by increasing the canvas size
backgroundColor = StrokeColor;
AD.resizeCanvas(AD.width+3,AD.height.value+3,AnchorPosition.MIDDLECENTER);
// Create boarder by increasing the canvas size
backgroundColor = BoarderColor;
AD.resizeCanvas(AD.width+35,AD.height.value+35,AnchorPosition.MIDDLECENTER);


**



// This function sets Author and copywrite notice to image
function AuthorText() **

var nameLayer = AD.artLayers.add();
nameLayer.kind = LayerKind.TEXT;
var TI = nameLayer.textItem;
TI.position = [AD.width.value - 5, AD.height.value - 25];
TI.contents = "Copyright © 2008 your name and site.com.";
TI.font = "Verdana-Italic";
TI.size = 12;
TI.tracking = 180;
TI.color = black;
//TI.fauxBold = true;

AD.activeLayer.rotate(-90,AnchorPosition.BOTTOMLEFT);
//AD.activeLayer.translate(-20,10);

**

// Sets Image info text to image
function ImageDataText(strData) **

//var tmpString = new String(strData);
var infoLayer = AD.artLayers.add();
infoLayer.kind = LayerKind.TEXT;
var TI = infoLayer.textItem;
TI.position = [20, AD.height.value - 5];
TI.contents = strData;
TI.font = "Verdana";
TI.size = 12;
TI.tracking = 50;
TI.color = black;
//TI.fauxBold = true;

//AD.activeLayer.rotate(-90,AnchorPosition.BOTTOMLEFT);

**

//Check if a document is open
if ( documents.length > 0 )
**
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PERCENT;

try
**
var docRef = activeDocument;

// Create a text layer at the front

var myLayerRef = docRef.artLayers.add();
myLayerRef.kind = LayerKind.TEXT;
myLayerRef.name = "Filename";
var myTextRef = myLayerRef.textItem;

//Set your parameters below this line

//If you wish to show the file extension, change the n to y in the line below, if not use n.
var ShowExtension = "n";
// Insert any text to appear before the filename, such as your name and copyright info between the quotes.
//If you do not want extra text, delete between the quotes (but leave the quotes in).
var TextBefore = "";

// Insert any text to appear after the filename between the quotes.
//If you do not want extra text, delete between the quotes (but leave the quotes in).
var TextAfter = "";

// Set font size in Points
myTextRef.size = 12;

//Set font - use GetFontName.js to get exact name
myTextRef.font = "Verdana-Italic";

//Set text colour in RGB values
var newColor = new SolidColor();
newColor.rgb.red = 0;
newColor.rgb.green = 0;
newColor.rgb.blue = 0;
myTextRef.color = newColor;

// Set the position of the text - percentages from left first, then from top.
myTextRef.position = new Array( 2, 2);

// Set the Blend Mode of the Text Layer. The name must be in CAPITALS - ie change NORMAL to DIFFERENCE.
myLayerRef.blendMode = BlendMode.NORMAL;

// select opacity in percentage
myLayerRef.opacity = 100;

// The following code strips the extension and writes tha text layer. fname = file name only

di=(docRef.name).indexOf(".");
fname = (docRef.name).substr(0, di);
//use extension if set
if ( ShowExtension == "y" )
**
fname = docRef.name
**


myTextRef.contents = TextBefore + " " + fname + " " + TextAfter;


**
catch( e )
**
// An error occurred. Restore ruler units, then propagate the error back
// to the user
preferences.rulerUnits = originalRulerUnits;
throw e;
**

// Everything went Ok. Restore ruler units
preferences.rulerUnits = originalRulerUnits;
**
else
**
alert( "You must have a document open to add the filename!" );
**



// Sets image data to a string that will later be used to set into the image
function getExifData() **

// Get exif data from file
var exifData = AD.info.exif.toString();

// Use this function to put string into array.
// Returns tempArray
var exifDataArray = explodeArray(exifData,",");



// Get the info I want
for(n = 0; n < exifDataArray.length; n = n + 1 ) **

var stringTemp=exifDataArray[n]
//alert(n + ": " + stringTemp); //Show what's coming out of array
if(stringTemp.indexOf("Exposure Time")!=-1)**
var expTime = exifDataArray[n+1];
**

if(stringTemp.indexOf("Date Time Original")!=-1)**
var phoTime = exifDataArray[n+1];
var dateArray1 = phoTime.split(" ", 1);
phoTime = dateArray1[0];
var dateArray2 = phoTime.split(":");

var monthsArray =["January","February","March","April","May","June","July","August","September","October","November","December"];
phoTime = monthsArray[dateArray2[1]-1]+" "+dateArray2[2]+" "+dateArray2[0];
**

if(stringTemp.indexOf("Model")!=-1)**
var cameraModel = exifDataArray[n+1];
**

if(stringTemp.indexOf("F-Stop")!=-1)**
var fstop = exifDataArray[n+1];
**

if(stringTemp.indexOf("Focal Length")!=-1)**
var focal = exifDataArray[n+1];
**

if(stringTemp.indexOf("ISO Speed Ratings")!=-1)**
var iso = exifDataArray[n+1];
**

** // End of For loop


// Now take this data to produce a string
//var strTemp = new String("Image Info: "+expTime+" "+fstop+" ISO:"+iso);
//+"\u000DLens: "+lens+" Focal Lenth: "+focal+"\u000DDate photo taken: "+phoTime);

var strTemp = cameraModel + " "+phoTime+" "+expTime+" "+fstop+" ISO:"+iso+" Focal Length:"+focal;

return strTemp;

**




// Save File
function SaveJPEG(inFileName) **
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 9;
activeDocument.saveAs( File( inFileName ), jpegOptions );
**


//function below credited to 'bradles' over at the Adobe User to User forums.
function explodeArray(item,delimiter) **

tempArray=new Array(1);
var Count=0;
var tempString=new String(item);
while (tempString.indexOf(delimiter)>0) **
tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1);
Count=Count+1
**
tempArray[Count]=tempString;
return tempArray;
**
// Save File
function SaveJPEG(inFileName) **
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 9;
activeDocument.saveAs( File( inFileName ), jpegOptions );
**


//function below credited to 'bradles' over at the Adobe User to User forums.
function explodeArray(item,delimiter) **

tempArray=new Array(1);
var Count=0;
var tempString=new String(item);
while (tempString.indexOf(delimiter)>0) **
tempArray[Count]=tempString.substr(0,tempString.indexOf(delimiter));
tempString=tempString.substr(tempString.indexOf(delimiter)+1,tempString.length-tempString.indexOf(delimiter)+1);
Count=Count+1
**
tempArray[Count]=tempString;
return tempArray;
**
 
Superb, thanks guys!
 
Back
Top