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

ExtendScript resize errors

Community Beginner ,
Dec 16, 2020 Dec 16, 2020

Copy link to clipboard

Copied

I am having problems with an ExtendScript I am writing to be used by a collegue on a Windows computer. Everything runs fine on my MacOS computer but on her Windows machine the resizing works really wierd. Due to the Covid situation I don't have access to her computer for direct debugging.

 

I am using a resize statement like this:

doc.resizeImage(UnitValue(25,'px'),null,null,ResampleMethod.BICUBIC);

But her output is an image that is 0.00694444444444 pixels. Is there a know issue with UnitValue on Windows or something. Do anyone have suggestions on workarounds or other things to try?

TOPICS
Actions and scripting , Windows

Views

445

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

Community Expert , Dec 16, 2020 Dec 16, 2020

Have you tried setting the rulerunits within the Script? 

preferences.rulerUnits = Units.PIXELS;

Votes

Translate

Translate
Adobe
Community Expert ,
Dec 16, 2020 Dec 16, 2020

Copy link to clipboard

Copied

Photoshop cannot produce an image that is less than a pixel wide, so what exactly are the resulting image’s pixel dimensions? 

 

Edit: What are the images’ resolutions? 

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 ,
Dec 16, 2020 Dec 16, 2020

Copy link to clipboard

Copied

Well, I am not sure as I not have access to the computer, but that is the output of doc.width * doc.height

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 ,
Dec 16, 2020 Dec 16, 2020

Copy link to clipboard

Copied

The same output on my Mac is 625.

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 ,
Dec 16, 2020 Dec 16, 2020

Copy link to clipboard

Copied

What are the resolutions of the images? 

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 ,
Dec 16, 2020 Dec 16, 2020

Copy link to clipboard

Copied

This is part of a larger process so the end image is not 0.00694444444444. What I do is reduce the size temporarly to do some analyzing that would otherwise be too time consuming. The input images may have varying sizes but are usually 1000x1000.

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 ,
Dec 16, 2020 Dec 16, 2020

Copy link to clipboard

Copied

Have the resulting file sent to you and post it please. 

Because I already stated a Photoshop-image-file cannot have less than 1px width … and »0.00694444444444 pixels« would be that. 

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 ,
Dec 16, 2020 Dec 16, 2020

Copy link to clipboard

Copied

Try using the scriptlistener plugin instead.
I write on mac and deliver for windows as well.

If all else fails, the fastest workaround is using scriptlistener code. It
usually works fine cross-platform...

Just install the plugin, do the things you want to do in photoshop and
you'll see a file appear on your desktop from where you can just copy paste
the code you need.

Best of luck!

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 ,
Dec 16, 2020 Dec 16, 2020

Copy link to clipboard

Copied

I have actually had more trouble with scriptlistner code before when trying to build for others (at least when they had other PS versions) but that definitely is worth trying. Thanks for the suggestion!

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 ,
Dec 16, 2020 Dec 16, 2020

Copy link to clipboard

Copied

Have you tried setting the rulerunits within the Script? 

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
Community Beginner ,
Dec 16, 2020 Dec 16, 2020

Copy link to clipboard

Copied

No, I haven't but that sounds like something worth doing!

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 ,
Dec 16, 2020 Dec 16, 2020

Copy link to clipboard

Copied

It does indeed seem like Photoshop ignores the UnitValue setting and uses the rulerUnits setting instead when I do some tests on my computer so this is very promising.

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 ,
Dec 16, 2020 Dec 16, 2020

Copy link to clipboard

Copied

Yes, that was it. Thank you!

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 ,
Dec 18, 2020 Dec 18, 2020

Copy link to clipboard

Copied

Before changing the ruler units, it is generally a good idea to do this near the head of the script:

 

// Save the current ruler units
var savedRuler = app.preferences.rulerUnits; 

 

Then add this towards the tail of the script after changing the ruler units to px and doing your stuff:

 

// Restore the saved ruler units
app.preferences.rulerUnits = savedRuler;

 

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 ,
Dec 18, 2020 Dec 18, 2020

Copy link to clipboard

Copied

LATEST

Yes, I have already implemented a similar restore in my script.

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