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

Scale manual vs. javacript

Explorer ,
Nov 06, 2018 Nov 06, 2018

Copy link to clipboard

Copied

I have a javascript that creates a 3D book. If I comment out the code shown by the arrow

CodeLine.jpg

and scale the final file in Photoshop, it looks like this:

Before.jpg

Note the area marked in red. If I uncomment the line to scale the book by the same 28% I used manually, it looks like this:

After.jpg

Any idea why I get a different result when scaled by hand vs. javascript? Thanks.

TOPICS
Actions and scripting

Views

1.0K

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

People's Champ , Nov 08, 2018 Nov 08, 2018

Nothing is unclear without your original file. It feels like you're using effects. If so, then with manual scaling, they are also scaled by default. If you use effects for a layer, then using DOM code you will not be able to scale them. It is necessary to use the AM version of the code in the same way as is used in Actions.

UPD

What does this script give?

var d = new ActionDescriptor();

d.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("percentUnit"), 28);

d.putBoolean(stringIDToTypeID("sca

...

Votes

Translate

Translate
Adobe
Community Expert ,
Nov 06, 2018 Nov 06, 2018

Copy link to clipboard

Copied

Have you tried converting all the values to numbers and not having unit values as px? I've gotten odd results with some math functions if I don't make sure everything is numbers.

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
Explorer ,
Nov 07, 2018 Nov 07, 2018

Copy link to clipboard

Copied

Hi Chuck. I tried using points but that didn't work either. There is only 1 layer. The image size before scaling is 828 x 1381. I want to scale it by 28% to get 231 x 386. I can't attach the file as it's 1279 x 1560 px so it will scale down.

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 ,
Nov 06, 2018 Nov 06, 2018

Copy link to clipboard

Copied

try adding the below before your initial variables.

var setRule = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;

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
Explorer ,
Nov 07, 2018 Nov 07, 2018

Copy link to clipboard

Copied

Thanks for the suggestion. I tried this but no luck. I'll try Chuck Uebele's suggestion next.

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
People's Champ ,
Nov 06, 2018 Nov 06, 2018

Copy link to clipboard

Copied

Is it one layer or more? Are there any effects?
It would be best to look at your entire file. And explain exactly how you want to resize your file at the end.

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 ,
Nov 07, 2018 Nov 07, 2018

Copy link to clipboard

Copied

I tried using this script and a doc size starting at 828X1381. I got an image of 232X387 using both the script and manually changing the size. 28% of 828 is 231.84, so rounded off it would be 232, which is what I got.

#target photoshop

var doc = activeDocument

doc.resizeImage(doc.width*.28,undefined,undefined,ResampleMethod.BICUBIC)

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
Explorer ,
Nov 08, 2018 Nov 08, 2018

Copy link to clipboard

Copied

Hi Chuck, I have no problem having it scale 28%. My problem is scaling manually vs. using javascript. If you look at my screenshots, the file that is scaled manually has no blur in the red area. The file that uses the javascript resize has a noticeable blur in the red area.

Thanks.

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
People's Champ ,
Nov 08, 2018 Nov 08, 2018

Copy link to clipboard

Copied

What interpolation do you use for manual scaling?

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
Explorer ,
Nov 08, 2018 Nov 08, 2018

Copy link to clipboard

Copied

The same as the javascript: BICUBIC.

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
People's Champ ,
Nov 08, 2018 Nov 08, 2018

Copy link to clipboard

Copied

Create a new Action and write your manual scaling in it.

Play the action on the original file.

What is the result?

If it coincides with your manual scaling, then it is advisable to take a look at your Action and script and compare them.

Your original file is also desirable.)

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
Explorer ,
Nov 08, 2018 Nov 08, 2018

Copy link to clipboard

Copied

Hi r-bin, I created a new Action and played it. I get the same result as when I manually scale it. It looks correct. The action and the script look the same; scale by 28% with BICUBIC. One file is correct and one isn't.

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
People's Champ ,
Nov 08, 2018 Nov 08, 2018

Copy link to clipboard

Copied

What exactly the file sizes (height, width) are in pixels after the script and after manual scaling. Do they match absolutely?

Try to use in the script

activeDocument.resizeImage(UnitValue(28, "%"), null, null, ResampleMethod.BICUBIC)

and

activeDocument.resizeImage(UnitValue(28, "%"), UnitValue(28, "%"), null, ResampleMethod.BICUBIC)

What is the result?

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
Explorer ,
Nov 08, 2018 Nov 08, 2018

Copy link to clipboard

Copied

Hello r-bin. I tried both ways and got the same results:

9781284121810_fullisbn_Email_3Dsm_232w400h.png

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
People's Champ ,
Nov 08, 2018 Nov 08, 2018

Copy link to clipboard

Copied

Nothing is unclear without your original file. It feels like you're using effects. If so, then with manual scaling, they are also scaled by default. If you use effects for a layer, then using DOM code you will not be able to scale them. It is necessary to use the AM version of the code in the same way as is used in Actions.

UPD

What does this script give?

var d = new ActionDescriptor();

d.putUnitDouble(stringIDToTypeID("width"), stringIDToTypeID("percentUnit"), 28);

d.putBoolean(stringIDToTypeID("scaleStyles"), true);

d.putBoolean(stringIDToTypeID("constrainProportions"), true);

d.putEnumerated(charIDToTypeID("Intr"), stringIDToTypeID("interpolationType"), stringIDToTypeID("bicubic"));

executeAction(stringIDToTypeID("imageSize"), d, DialogModes.NO);

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
Explorer ,
Nov 08, 2018 Nov 08, 2018

Copy link to clipboard

Copied

LATEST

Hello r-bin. You're a genius. This worked.

9781284121810_fullisbn_Email_3Dsm_232w400h.png

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