Skip to main content
bflieck
Participating Frequently
August 28, 2017
Question

if width and height equal set size

  • August 28, 2017
  • 1 reply
  • 789 views

I'm trying to set 2 separate width and height variable that will have an if statment wrapped around it and i don't know the best way to start.

var imagesize = [{"width":1800, "height":2160},{"width":1575, "height":2800},];

if(doc.height || doc.width = imagesize)

{do something;}

else

{ don't do a thing;}

This topic has been closed for replies.

1 reply

JJMack
Community Expert
Community Expert
August 28, 2017

What units is Photoshop using. Start with setting Photoshop ruler units. So you know what you are dealing with when you use 1800, 2160, 1575, 2800. For example when ruler units equal persent doc.height and doc.width will always be 100 not anything else. When set to inches what 1800" is depends on the document resolution some units are relative to the document's resolution.

JJMack
bflieck
bflieckAuthor
Participating Frequently
August 28, 2017

like adding this to the top?

var rulerUnits = app.preferences.rulerUnits;

app.preferences.rulerUnits = Units.PIXELS;

JJMack
Community Expert
Community Expert
August 28, 2017

Yes then add the logic needed  to seperate the douments sizes. I do not know javascripts so I would just use simple If  ,else if,  else.  You code does not look right to me.

if (doc.height=2160 & doc.width=1800) {do something;}

else if (doc.height=28000 & doc.width=1575) {do something;}

else { don't do a thing;}

if ((doc.height=2160 & doc.width=1800) || (doc.height=28000 & doc.width=1575) ) {do something;}

else { don't do a thing;}

JJMack