Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Why does my doc.resizeImage(3.167, undefined, undefined, ResampleMethod.NONE); code line not work?

New Here ,
Nov 21, 2013 Nov 21, 2013

#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

TOPICS
Actions and scripting
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Advisor ,
Nov 21, 2013 Nov 21, 2013

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)

http://tomaxxi.com

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 21, 2013 Nov 21, 2013

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;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 21, 2013 Nov 21, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 21, 2013 Nov 21, 2013
LATEST

Ok...Thx. Resizing by resolution works. I will have to do the math to figure out the exact width.

I appreciate your response.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines