Search code examples
photoshop-script

Photoshop script odd number


I need to open an image and check that the width and height are even numbers. If they are not -1px.

How do I check to see if a number is odd?

291px would = 290px

333px would = 332px

121px would = 120px


Solution

  • Untested, but you should be able to do this:

    if(x&1) {x--}
    

    That tests if the least significant bit is one (i.e. x is odd) and decrements it if so.