INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Expression Help - Comparing two fields with math functions  (Read 335 times)

mvandyke

  • World Citizen
  • ***
  • Posts: 159
Expression Help - Comparing two fields with math functions
« on: March 13, 2021, 08:30:34 am »

I want to be able to compare two fields [image height] and [image width] provide a numeric value from the two fields

For example , create add an expression column that creates a number based on image height divided by image width.  Example image height = 2000 and image width = 1000 would provide a number of 2.

I would like this so that I can see what images are portrait based that should be landscape based.  I have tons of images and this formula would help me sort those files and then rotate those images.

I've tried the math function, straight divide function and not getting the results that I need.

Thanks
Matt
Logged

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2619
Re: Expression Help - Comparing two fields with math functions
« Reply #1 on: March 13, 2021, 09:52:19 am »

Did you remember to escape the fwd-slash?
Code: [Select]
Math([Width]//[Height])
You can use something like this to output a Landscape/Portrait/Square:
Code: [Select]
if(isequal([width],[height]), square, ifcase(Math([width]//[height]), 4, 0.8, portrait, 1.2, squarish, 1000, landscape))
Also, there's already an [Aspect Ratio] field, maybe you can use that.

edit: no need to use save()
Logged

mvandyke

  • World Citizen
  • ***
  • Posts: 159
Re: Expression Help - Comparing two fields with math functions
« Reply #2 on: March 13, 2021, 10:18:25 am »

Did you remember to escape the fwd-slash?
Code: [Select]
Math([Width]//[Height])
You can use something like this to output a Landscape/Portrait/Square:
Code: [Select]
save(Math([width]//[height]),ratio)if(isequal([width],[height]), square, ifcase([ratio],4, 0.8, portrait, 1.2, squarish, 1000, landscape))

Also, there's already an [Aspect Ratio] field, maybe you can use that.

That was it -  the //

Thanks much Zybex appreciate the help and will explore the other options that you provided.
Logged
Pages: [1]   Go Up