Copy link to clipboard
Copied
Hil all,
I'm writting a function who resize an image:
function resampling_function(serializedObject){
app.displayDialogs = DialogModes.NO;
var obj = eval(serializedObject);
var file_path = decodeURI(obj.file_path);
var horizontal_scale = obj.horizontal_scale;
var vertical_scale = obj.vertical_scale;
var resolution = obj.resolution;
var resample_method = eval(obj.resample_method);
var img_file = new File(file_path);
var ps_doc = app.open(img_file);
app.preferences.rulerUnits = Units.PERCENT;
ps_doc.resizeImage(horizontal_scale, undefined, undefined, ResampleMethod.NONE);
ps_doc_resizeImage(undefined, undefined, resolution, resample_method);
ps_doc.save();
ps_doc.close();
app.displayDialogs = DialogModes.ALL;
}
1) I would like to change the width and height in percent
2) after I would like to resample the image with a target resolution.
But this 2 lines doesn't work
ps_doc.resizeImage(horizontal_scale, undefined, undefined, ResampleMethod.NONE);
ps_doc_resizeImage(undefined, undefined, resolution, resample_method);
Has someone an idea how to do this?
Thanks!
Copy link to clipboard
Copied
It is hard to say without seeing what serializedObject is but one thing I know is wrong is when the resample method is none you can only set the resolution. If you want to change the width you either need to do the math to determine what resolution will give you that width or resample.
As you are resampling anyway, I do not see why you want to resize twice. You could be the desired width and resolution with one resize call.
Copy link to clipboard
Copied
Hi,
Thanks for your reply … I'm quite bad in algorithm and I can't find my error…
I do this:
For example I have an image in 50% in indesign with a resolution of 2000 DPI
I call my function resizeImage(50, 50, 1200, ResampleMethod.BICUBICSHARPER);
app.preferences.rulerUnits = Units.PERCENT;
ps_doc.resizeImage(horizontal_scale, vertical_scale, resolution, resample_method);
But the results is wrong. The final image is in 60% in indesign and I don't understand why?
Copy link to clipboard
Copied
I don't do much InDesign scripting but I think that changing the size or resolution of an image after it has been placed in InDesign does not change the size of the placed image. At least that is the it works if done manually in the GUI. Edit a placed image using the InDesign links panel, resize, and update. The the actual resolution of the placed image may change but the size of the image in InDesign does not change.
You need to resize in InDesign or both Photoshop and InDesign.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now