Photoshop Script does not change the color anymore

93 Views Asked by At

This script should change the background color. Until 10 minutes ago that worked too. I have not changed anything on the script and even the backup copy of the script shows no other efect. So there must be an mistake in the script, which is efect by the settings. Has anybody a idea?

Thanks for your efforts

var srcDoc = app.activeDocument;
var color = app.backgroundColor;

var l = srcDoc.width.value;
var h = srcDoc.height.value;

if (l/h >16/9)
{
  color.rgb.red = 255;
  color.rgb.green = 255;
  color.rgb.blue = 255;
  app.backgroundColor = color;
  app.activeDocument.resizeCanvas(l, l/(16/9), AnchorPosition.MIDDLECENTER);
}
1

There are 1 best solutions below

1
rborum On

Try being more explicit in the logic of your if statement, like you are in your resizeCanvas function call. It might be that the steps are executing out of order and the condition is never met.

var srcDoc = app.activeDocument;
var color = app.backgroundColor;

var l = srcDoc.width.value;
var h = srcDoc.height.value;

if (l/h > (16/9) )
{
  color.rgb.red = 255;
  color.rgb.green = 255;
  color.rgb.blue = 255;
  app.backgroundColor = color;
  app.activeDocument.resizeCanvas(l, l/(16/9), AnchorPosition.MIDDLECENTER);
}