Photoshop Script for easy scaling of images of

14 downloads 271 Views 706KB Size Report
or InDesign document at a similar scale (e.g. when making an image composition) or allows the automatization of (pre- made) scale bar placement using the ...
Photoshop Script for easy scaling of images of (archaeological) objects, maps, field images, etc. E. Pop - May 2017 This script (modified after Mike Hale1), allows the user to change the document scale of an image in Photoshop using an object within the image of known length (e.g. scalebar, measurement between two fixed points). Its working is similar to the image > analyse > set scale function, but rather than adding the measurement scale as an attribute in Photoshop, it changes the document scale itself. This is very convenient when ‘placing’ multiple images in a Photoshop or InDesign document at a similar scale (e.g. when making an image composition) or allows the automatization of (premade) scale bar placement using the batch function. How to install and use 1. Save the code below in notepad as a .jsx file (e.g. “CorrectScaleV2.jsx”) 2. Pin the script to Photoshop in the taskbar for easy access (drag jsx to Photoshop in taskbar) 3. Open the to be scaled document in photoshop, drag a line between two points for which the length is known and activate the script (from taskbar or via file > scripts)

4. Fill in the known length in cm in the prompt that appears, hit ok or press enter

1

https://forums.adobe.com/thread/1233856

5. The document scale has been changed, save document to finalize Script (save as .jsx file): main(); function main(){ if(!documents.length) return; if(!activeDocument.pathItems.length) return; // with a line shape layer active and no other paths in the document var line = measureLine(activeDocument.pathItems[0]); var cm = prompt("Enter the actual size in centimetres","","Correct scale v0.2") if (cm == null) { return; } else if (cm == "") { return; } else { activeDocument.pathItems[0].remove(); var newres =((((activeDocument.resolution)*((Number(line[2]))/28.34674469))) / cm); activeDocument.resizeImage (undefined, undefined, newres, ResampleMethod.NONE); activeDocument.measurementScale.pixelLength = (newres/2.54) }

} function measureLine(path){ //By Mike Hale var res = new Array; var lineStart = path.subPathItems[0].pathPoints[0].anchor; res.push( lineStart ); var lineEnd = path.subPathItems[0].pathPoints[3].anchor; res.push( lineEnd ); var a = Math.max(lineStart[0],lineEnd[0])-Math.min(lineStart[0],lineEnd[0]); var o = Math.max(lineStart[1],lineEnd[1])-Math.min(lineStart[1],lineEnd[1]); var c = Math.sqrt((a*a)+(o*o)); res.push(c); var ang = (180/Math.PI) * Math.atan2(o,a); if(lineStart[1] < lineEnd[1]){//negative angle ang = -ang; }; res.push(ang); return res; }

Suggest Documents