ExtendScript resize errors

Community Beginner ,
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, Mac, Windows

Views

91

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

1 Correct Answer

LEGEND , Dec 16, 2020
c.pfaffenbichler LEGEND , Dec 16, 2020
Have you tried setting the rulerunits within the Script? preferences.rulerUnits = Units.PIXELS;

Likes

Translate

Translate
Jump to answer Jump to answer
LEGEND ,
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? 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Dec 16, 2020

Copy link to clipboard

Copied

The same output on my Mac is 625.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
LEGEND ,
Dec 16, 2020

Copy link to clipboard

Copied

What are the resolutions of the images? 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
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.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
LEGEND ,
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. 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Participant ,
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!

--
JEF BRACKE
Image Processor / Automation Developer | NER Digital Factory - Photographers
Cell. +32498495059
jef.bracke@veepee.com <%20jef.bracke@veepee.com>
Humaniteitslaan 292/1 • 1190 • VORST
[image: veepee]

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
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!

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
LEGEND ,
Dec 16, 2020

Copy link to clipboard

Copied

Have you tried setting the rulerunits within the Script? 

preferences.rulerUnits = Units.PIXELS;

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Dec 16, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
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.

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Dec 16, 2020

Copy link to clipboard

Copied

Yes, that was it. Thank you!

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
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;

 

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Per Martinson AUTHOR LATEST
Community Beginner ,
Dec 18, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more