INTERACT FORUM

Please login or register.

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

Author Topic: Possible to Restrict Calculated Library Field  (Read 412 times)

Scolex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1116
  • Cheers
Possible to Restrict Calculated Library Field
« on: April 25, 2022, 04:40:45 pm »

I am wondering if it is possible to create a calculated library field and give it more restrictions than just media type.
To be more specific I have a rather large collection of artist images that I would like to sort by aspect ratio.
Something similar to this.
[Media Type]=[Image] [Genre]=[Artist Images] ([Width]/[Height])=[Aspect:]
Keep in mind expressions might as well be written in Sanskrit so I have no idea how to format the expression.
I would also like to limit the output to 2 decimal places.
Logged
Sean

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2365
Re: Possible to Restrict Calculated Library Field
« Reply #1 on: April 26, 2022, 06:22:18 am »

You don't need to filter. This expression gives you the aspect ratio for any file that has a [height] defined, so it works for images and videos:

Code: [Select]
if(not(isempty([height])),math(trunc([width]//[height],2)),)
Logged

Scolex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1116
  • Cheers
Re: Possible to Restrict Calculated Library Field
« Reply #2 on: April 26, 2022, 08:02:49 am »

You don't need to filter. This expression gives you the aspect ratio for any file that has a [height] defined, so it works for images and videos:

Code: [Select]
if(not(isempty([height])),math(trunc([width]//[height],2)),)

Thank you it worked flawlessly!
After I posted I did a little reading and if I understand correctly something like this is an on demand calculation so it's only calculated when you are viewing that tag. Due to that fact assuming I am correct I don't need to be concerned with it doing the calc on 10s of thousands of files since I will only be viewing it in smartlists that reduce the number of files greatly.
Logged
Sean

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2365
Re: Possible to Restrict Calculated Library Field
« Reply #3 on: April 26, 2022, 08:04:13 am »

That is correct.
Logged
Pages: [1]   Go Up