Skip to main content
Participant
October 11, 2022
Answered

Resample Method not exectued

  • October 11, 2022
  • 4 replies
  • 292 views

I am trying to resize an image using photoshop with below command.

 

alert("Before Resizing");   -> executed
            // document.resizeImage(parseInt(row.width), undefined, undefined); //working

            document.resizeImage(parseInt(row.width), undefined, undefined,ResampleMethod.NONE); //not working
            alert("After Resizing");  -> not executed because ResampleMethod.NONE is added.
 
As from the code, adding ResampleMethod to resizeImage results in error and code execution is stopped.
 
I am using the code in jsx file
This topic has been closed for replies.
Correct answer Chuck Uebele

You have a dimention in the width. You can only have a value in the resolution when you are using  ResampleMethod.NONE. Otherwise, you are actually changing the image's dimension size.

4 replies

Chuck Uebele
Community Expert
Community Expert
October 21, 2022

Yes, if you want to calculate a new resolution and not use any resampling method, you can only populate the resolution field and leave the others as undefined.

Participant
October 21, 2022

Thanks to all. It seems the new resolution should be calculated seperately. The resizeImage function changes the height automatically while width is passed. But does not alter the resolution.

 

The new resolution should be manually calculated.

newResolution = document.resolution * (originalWidth / parseInt(row.width));
document.resizeImage(null, null, newResolution, ResampleMethod.NONE);
document.resizeImage(UnitValue(parseInt(row.width), "pt"), null, null);
If the width is changed, the height will be changed programatically, which caused an impression, ResampleMethod.NONE will set the resolution too.

Chuck Uebele
Community Expert
Community Expert
October 18, 2022
document.resizeImage(parseInt(row.width), undefined, undefined); //Ok

document.resizeImage(parseInt(500), undefined, undefined,ResampleMethod.NONE); //not ok

document.resizeImage(undefined, undefined, 250,ResampleMethod.NONE); //ok
Chuck Uebele
Community Expert
Chuck UebeleCommunity ExpertCorrect answer
Community Expert
October 18, 2022

You have a dimention in the width. You can only have a value in the resolution when you are using  ResampleMethod.NONE. Otherwise, you are actually changing the image's dimension size.