Resource

Resource Basics

Resource Name Filter With Exactly n Labels
Resource Version 1.0
Category Filter Script
Downloads 1194
Release Date 3/29/2021 9:32:52 AM
 

Resource Details

Description This script will filter those images with an exact number of assigned catalog labels. The number is configurable.
Installation Instructions Download script to your \Scripts\Filter folder
Usage Instructions Open the set of images
Start this filter
Enter the number of filters
Changes in this version n.a.
Special Requirements
 

Author Information

Author Name IDimager Support
 

Available Attachments

Attachment #1 FilterWithNLabels.png
 

Script

var
  ALabelCount: Integer;

function Initialize: Boolean;
var
  ALabels: String;
begin
  // return false to cancel the filter operation

  result := False;
  ALabelCount := ReadFromRegistry('FilterWithXLabels', 'LabelCount', 1);
  ALabels := IntToStr(ALabelCount);
  if AskInput('Label Count', 'How many labels should be assigned?', '', ALabels, False, nil) then
  begin
    if not IsValidNumberString(ALabels, False, '') then
      Say('Please enter a valid number')
    else
    begin
      ALabelCount := Trunc(StrToFLoat(ALabels));
      WriteToRegistry('FilterWithXLabels', 'LabelCount', ALabelCount);
      result := True;
    end;
  end;
end;

procedure Finalize;
begin

end;

function Filter(AItem: TImageItem): Boolean;
begin
  AItem.Fetch;
  result := AItem._PropCount = ALabelCount;
  //result := Catalog.CountPropsForImage(AItem, False) = 1;
end;