What's new
Photoshop Gurus Forum

Welcome to Photoshop Gurus forum. Register a free account today to become a member! It's completely free. Once signed in, you'll enjoy an ad-free experience and be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Reply to thread

There are times when only documents of 72PPI will work.

But this seems as part of analysis.

The code I provided will change the document to 72PPI if was anything else then change it back to what it was originaly.

In your case, I think you just need.


[CODE]#target photoshop;

var doc = activeDocument;

var res = doc.resolution;

//change to 72 PPI

if(doc.resolution != 72) doc.resizeImage(undefined, undefined, 72, ResampleMethod.NONE);

[/CODE]


You are setting the size then trying to record the measurments without making any?


Here is the first bit of your code..

[CODE]

function setMeasurementScale() {

var desc8 = new ActionDescriptor();

var ref4 = new ActionReference();

ref4.putProperty( charIDToTypeID('Prpr'), stringIDToTypeID('measurementScale') );

ref4.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );

desc8.putReference( charIDToTypeID('null'), ref4 );

var desc9 = new ActionDescriptor();

desc9.putString( charIDToTypeID('Nm  '), '85px_to_3cm' );

desc9.putInteger( stringIDToTypeID('pixelLength'), 85 );

desc9.putDouble( stringIDToTypeID('logicalLength'), 3.000000 );

desc9.putString( stringIDToTypeID('logicalUnits'), 'cm' );

desc8.putObject( charIDToTypeID('T   '), stringIDToTypeID('measurementScale'), desc9 );

executeAction( charIDToTypeID('setd'), desc8, DialogModes.NO );

};

[/CODE]

And the second bit.


[CODE]

function recordMeasurements() {

var desc10 = new ActionDescriptor();

desc10.putEnumerated( charIDToTypeID('Srce'), stringIDToTypeID('measurementSource'), charIDToTypeID('fsel') );

var list1 = new ActionList();

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('Angle') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('Area') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('Circularity') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('Count') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('DateTime') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('Document') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('GrayValueMaximum') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('GrayValueMean') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('GrayValueMedian') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('GrayValueMinimum') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('Height') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('Histogram') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('IntegratedDensity') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('Label') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('Length') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('Perimeter') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('Scale') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('ScaleFactor') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('ScaleUnits') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('Source') );

list1.putEnumerated( stringIDToTypeID('measurementDataPoint'), stringIDToTypeID('Width') );

desc10.putList( stringIDToTypeID('dataPoints'), list1 );

executeAction( stringIDToTypeID('recordMeasurements'), desc10, DialogModes.NO );

};

[/CODE]


By the way a selection is not modal so yes you can make changes.


What is our favorite program/app? (Hint - it begins and ends with the letter P)
Back
Top