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

Scripting: resize image based on resolution

Community Beginner ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

I have a variable I capture that has a resolution value which is a pixels/cm value.  I then want to resize an image using that resolution variable and make sure the unit measurement is set to pixel/cm and make sure resampling is off so that it resizes 1:1.

 

I thought that:

imageResize(undefined,undefined,res.variable,ResampleMethod.None)

would be the right fit, but it is not. I tried using the scriptListener to grab those actions by doing it manually, but no luck. Can someone help?

 

imageresize.jpg 

TOPICS
Actions and scripting

Views

3.5K

Translate

Translate

Report

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

correct answers 1 Correct answer

Contributor , Jan 03, 2020 Jan 03, 2020

I think you need to convert cm to pixels/inch

 

NewResolution  = res.variable x 2.54

imageResize(undefined,undefined,NewResolution,ResampleMethod.NONE)

Votes

Translate

Translate
Adobe
Community Expert ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

That would be a Crop not a resize. You need to discard part of you image to change its aspect ratio to 1:1 if its not square. You need to have some process to do that. ie. Make a centered crop or crop orientation from some corner.  Or have  an interactive action where you can position the 1:1 aspect crop selection for the action. It not hard to do.

 

image.png

JJMack

Votes

Translate

Translate

Report

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
Contributor ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

You need to convert cm to pixels in the variable res.variable

Votes

Translate

Translate

Report

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
Contributor ,
Jan 03, 2020 Jan 03, 2020

Copy link to clipboard

Copied

I think you need to convert cm to pixels/inch

 

NewResolution  = res.variable x 2.54

imageResize(undefined,undefined,NewResolution,ResampleMethod.NONE)

Votes

Translate

Translate

Report

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
Community Expert ,
Jan 04, 2020 Jan 04, 2020

Copy link to clipboard

Copied

They want an images with a 1:1  Aspect Ratio. If they resize unconstrained to a 1:1 Aspect Ratio no matter what resolution the document has the image will distort. If they Crop the image to a 1:1 aspect ratio they will lose some image content the images resolution will not change.  They could also add canvas so the image has a boarder to make the image have a 1:1 aspect ratio. They need to decide how the want to change the image to have a 1:1 aspect ratio. Add a Boarder, Crop, or Distort. Content Aware Scale also distorts the image but tries to preserve recognized objects aspect ratio their image looks like a unique finger print it will distort if resized to a 1:1 aspect ratio. 

 

They do not want to Resample they must Crop or Add Canvas.

JJMack

Votes

Translate

Translate

Report

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
Community Beginner ,
Jan 05, 2020 Jan 05, 2020

Copy link to clipboard

Copied

LATEST

For anyone who comes along later on the thread. I don't want a 1:1 aspect ratio. I want a 1:1 image size. Specifically, I want to resize a fingerprint image with a ruler so that it's actually the size of the real fingerprint. 

I thought that the Adjustment > Image Size modal popup would reflect the script's instructions to unchecked Resample and use pixel/cm selection but it did not.  Adding the *2.54 to the script did the job as planned.

Votes

Translate

Translate

Report

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