skip to Main Content

I have an image when manually resized to width 1000pts the resolution comes to 261.5pixels/inch

Original Image Dimensions

enter image description here

Manual Update width to 1000pts

enter image description here

The resolution downgraded to 261.5 px/in

When i try the same programmatically with js script the width changes but resolution is same as of the original image

JS Code

 document.resizeImage(UnitValue(parseInt(row.width),"pt"), null, null); //working

where row.width = 1000

Image dimensions after executing the js script

enter image description here

How to calculate the resolution of the image automatically and set to 261.5px/inch

2

Answers


  1. Chosen as BEST ANSWER

    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.


  2. Not sure if you want to shrink the image or the canvas. I’ve got with the former.

    Use app.activeDocument.resizeImage with a width, height and resolution of your image.

    resizemeth = ResampleMethod.BICUBIC;
    res = 72;
    w = 1000;
    h = 673;
    app.activeDocument.resizeImage(w, h, res, resizemeth);
    

    Also check what units you are using.

    alert(app.preferences.rulerUnits);

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search