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

how to reduce image witdh without resampling

Explorer ,
Aug 24, 2013 Aug 24, 2013

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!

TOPICS
Actions and scripting
664
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
Guru ,
Aug 24, 2013 Aug 24, 2013

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.

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
Explorer ,
Aug 24, 2013 Aug 24, 2013

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?

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 ,
Aug 24, 2013 Aug 24, 2013
LATEST

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.

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