Copy link to clipboard
Copied
#target Photoshop
// Set the ruler units to INCHES
var orig_ruler_units = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.INCHES;
doc.resizeImage(3.167, undefined, undefined, ResampleMethod.NONE);
// Remove all paths.
doc.pathItems.removeAll()
// Final clean-up - set units back to original photo units.
app.preferences.rulerUnits = orig_ruler_units;
var doc = null;
Getting "Error 21: undefined is not an object
Thx
Copy link to clipboard
Copied
You have to replace undefined with null.
It should look like this:
doc.resizeImage(3.167, null, null, ResampleMethod.NONE);
Hope that helps.
--
Marijan (tomaxxi)
Copy link to clipboard
Copied
Thx... I'm getting the same error.
#target Photoshop
// Set the ruler units to INCHES
var orig_ruler_units = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.INCHES;
doc.resizeImage(3.167, null, null, ResampleMethod.NONE);
// Remove all paths.
doc.pathItems.removeAll()
// Final clean-up - set units back to original photo units.
app.preferences.rulerUnits = orig_ruler_units;
var doc = null;
Copy link to clipboard
Copied
I see two things wrong with what you posted.
1. You have not defined doc. Either define it before the resize line or replace doc with app.activeDocument. That is way you are getting that error message.
2. When resample is set to none you can only change the res. To change the width you need to do the math to determine what res will result in the new width.
Using undefined instead of null is not the problem. If fact I recommend you continue to use undefined. Also setting doc to null at the end does not destroy the reference. It just changes what is stored in that variable. And with Photoshop scripts you don't need to do that kind of reference clean up. The variables defined by a script are destroyed when the script ends. They don;t stay in memory.
Copy link to clipboard
Copied
Ok...Thx. Resizing by resolution works. I will have to do the math to figure out the exact width.
I appreciate your response.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now