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

ExtendScript resize errors

Community Beginner ,
Dec 16, 2020 Dec 16, 2020

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
829
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

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;
Translate
Adobe
Community Expert ,
Dec 16, 2020 Dec 16, 2020

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? 

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

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

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

The same output on my Mac is 625.

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

What are the resolutions of the images? 

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

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.

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

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. 

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

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!

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

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!

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

Have you tried setting the rulerunits within the Script? 

preferences.rulerUnits = Units.PIXELS;
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
Community Beginner ,
Dec 16, 2020 Dec 16, 2020

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

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

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.

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

Yes, that was it. Thank you!

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

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;

 

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

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

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