ResampleMethod is not defined? Bug?

Hi everybody.

whenever I try/debug this code I get this error:

await app.activeDocument.resizeImage(undefined, undefined, 300, ResampleMethod.BILINEAR);

Bildschirmfoto 2021-10-27 um 23.41.59

First I thought: ok that’s not implemented yet, but it is in the documentation:
https://www.adobe.io/photoshop/uxp/2022/ps_reference/modules/constants/#resamplemethod

Which leads to my questions: Am I doing something wrong? Is the documentation wrong? Is this simply a bug? Maybe someone could help, please :slight_smile:

EDIT: I know I could probably do this with batchPlay, but my question is more about understanding the documentation and the debugger …

I believe you need to import them and it works only with API v2

const constants = require('photoshop').constants;
console.log(constants.ResampleMethod.BILINEAR);
1 Like

Thanks for your help! That actually makes sense, but leads to another question:
How would that look like in my example? I tried this (and a few other versions) but it still doesn’t work

async function customResize() {
	const app = require('photoshop').app;
	const constants = require('photoshop').constants;
	await require('photoshop').core.executeAsModal(async function(){
		await app.activeDocument.resizeImage(undefined, undefined, 300, ResampleMethod.NONE);
	});
};

The code works totally fine without the ResampleMethod.NONE, but doesn’t work when it’s there?

But you didn’t change how you use ResampleMethod. You don’t have it defined. You’ve imported the full constants object and ResampleMethod is in it. Check my example once more

You’re right of course, but I already tried that:

async function customResize() {
	const app = require('photoshop').app;
	const constants = require('photoshop').constants;
	await require('photoshop').core.executeAsModal(async function(){
		await app.activeDocument.resizeImage(undefined, undefined, 300, constants.ResampleMethod.NONE);
	});
};

It works fine with BILINEAR, BICUBIC or any other, but unfortunately not with NONE.

In Extendscript I always used this to change the image resolution, without affecting the amount of pixels in the image. But I simply can’t get it to work … maybe I should try batchPlay?!

Do you get a different error with NONE?

Yes! Finally I got an useful error message:

I tried every single ResampleMethod yesterday and the debugger never caught any errors. Obviously I missed trying NONE. So thanks for asking and pointing me in the right direction. Now I know that I have to use batchPlay …