Copy link to clipboard
Copied
I am using Photoshop 2020, on a windows 10 machine.
I have searched all sorts of photoshop scripting websites and I cannot seem to find a solution that works. I have a large image (6480x6480 pixels). In photoshop I can manually resize it to 648x648 and the details look well preserved (the 'diamonds' inside the letter T). BUT, when I try to resize using a script, I lose key details, where my 'diamonds' are now blurred out to what looks more like 'chrome'. fyi: The PSD file is file that applies a text effect (in this case, diamonds) to the inside of whatever you set your text string to be.
If I take my origianl 6480x6480 psd file and zoom till it is down to 10%, I can still see the jewelled diamond detail.
The script line I use to resize is:
app.documents[0].resizeImage (648, 648, 300, ResampleMethod.BICUBICSHARPER);
Even before I save the image as JPEG or PNG, you can already see the detail is lost even though I keep the resolution at 300 pixel/inch!
--- prior to the code line above, I initially tried this --
app.preferences.rulerUnits = Units.PIXELS; // use pixels
var sfw = new ExportOptionsSaveForWeb();
sfw.format = SaveDocumentType.PNG;
sfw.PNG8 = false; // use PNG-24
sfw.transparency = true;
// a bunch of code that successfully save the full size image and PNG files with NO LOSSES
app.documents[0].layers.getByName("Watermark").visible = true;
app.documents[0].layers.getByName("Background").visible = true;
app.documents[0].resizeImage(600, 600, null, ResampleMethod.BICUBICSHARPER); // width, height
var destFileName = "Blog6006Black.png";
app.documents[0].exportDocument(new File(destFolder + "/" + destFileName), ExportType.SAVEFORWEB, sfw);
... at this point I think I would even be happy with a script that does just a screenshot of my original large file as it appears inside photoshop
Flatten the image before resizing.
Then resize using this method: "deepUpscale" instead of "bicubicSharper".
Also for a flat image, try this plugin to reduce the size - https://pm.vogu35.ru/~c3c/plug-ins/c3cimagesize.htm
Copy link to clipboard
Copied
I doubt that the following AM function will result in anything different, however, it is worth a shot:
imageSize(648, 648, "bicubicSharper");
function imageSize(width, height, resampleMethod) {
function s2t(s) {
return app.stringIDToTypeID(s);
}
var descriptor = new ActionDescriptor();
descriptor.putUnitDouble( s2t( "width" ), s2t( "pixelsUnit" ), width );
descriptor.putUnitDouble( s2t( "height" ), s2t( "pixelsUnit" ), height );
descriptor.putEnumerated( s2t( "interfaceIconFrameDimmed" ), s2t( "interpolationType" ), s2t( resampleMethod ));
executeAction( s2t( "imageSize" ), descriptor, DialogModes.NO );
}
Copy link to clipboard
Copied
Thanks for you effort. I tried it out, but still got the 'chrome' effect.
I have literally spent 6 hours on this. It should be dead simple, but it's not (at least for me)
Copy link to clipboard
Copied
It is a huge reduction in size, my expectation wouldn't be the same level of detail.
Can you crop out a relevant section of the high res image for experimentation?
Copy link to clipboard
Copied
See my response to r-bin below. My current work-around is to export a 6480x6480 PNG file, have my script read in the PNG, resize it, and spit it out as a PNG. The work-around works (I get good detail in the shrunk down 648x648 PNG file), but I am sure it adds a bit of time to a script that already takes 1 minute 40 seconds to run.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
that extra line made the final result a tiny bit better but still no real detail.
The detailed image is a screenshot from a PNG file generated from a PSD files that has a file link to the original large PSD and it seems to look fine at an image height of 1624. I could try this at a smaller size, but I find refreshing links SLOW. The other image is when resizing the original large PSD file down to 648x648 using the extra line of code you recommended.
Copy link to clipboard
Copied
Flatten the image before resizing.
Then resize using this method: "deepUpscale" instead of "bicubicSharper".
Also for a flat image, try this plugin to reduce the size - https://pm.vogu35.ru/~c3c/plug-ins/c3cimagesize.htm
Copy link to clipboard
Copied
@r-bin - thanks, my test layer didn't contain any effects so I obviously missed that.