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?
Have you tried setting the rulerunits within the Script?
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?
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
Copy link to clipboard
Copied
The same output on my Mac is 625.
Copy link to clipboard
Copied
What are the resolutions of the images?
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.
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.
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!
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!
Copy link to clipboard
Copied
Have you tried setting the rulerunits within the Script?
Copy link to clipboard
Copied
No, I haven't but that sounds like something worth doing!
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.
Copy link to clipboard
Copied
Yes, that was it. Thank you!
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;
Copy link to clipboard
Copied
Yes, I have already implemented a similar restore in my script.