example for a custom thumb script

Post Reply
weidmic
moderator
Posts: 834
Joined: 04 Dec 06 22:21

example for a custom thumb script

Post by weidmic » 10 Jan 14 19:26

Hert was so kind to optimize my custom thumb scripts for Supreme V2 which I want to share

It is using 3 lines

First line:

Code: Select all

<FONT color="3300FF">%xmp:exif:FNumber - %xmp:exif:ExposureTime - %xmp:exif:FocalLength</FONT> B %exifmakernote:ExposureBracketValue %code
  function HasPortfolios: Boolean;
  var
    ACols: TImageCollections;
  begin
    result := False;
    ACols := TImageCollections.Create (TImageCollection, '');
    Catalog.EnumCollectionsForImage (ImageItem, ACols);
    result := ACols.Count > 0;
    ACols.Free;
  end;

begin
result := ToWideString('') + iif(not WideFileExists(ImageItem.Filename), 'Off', '');
// add PORTFOLIO indicator
if HasPortfolios then result := result + '<FONT color="#58FA58"> P</font>';
end;
%/code
Second line with the text GPS if image has GPS assigned to it:

Code: Select all

%ImageFileSizeShort  %code result := ToWideString('');
              
	      // add software ID
              if Pos('Capture', '%exif:Software') = 1 then
                result := result + '<FONT color="#888888 ">NX2</font>'
              else if Pos('Adobe DNG', '%exif:software') <> 0 then
                result := result + '<FONT color="#888888 ">ADC</font>'
              else if Pos('Photoshop', '%exif:software') <> 0 then
                result := result + '<FONT color="#888888 ">CS4</font>'
              else if Pos('Bibble', '%exif:software') <> 0 then
                result := result + '<FONT color="#888888 ">BIB</font>'
              else if Pos('Ver.1', '%exif:software') = 1 then
                result := result + '<FONT color="#888888 ">CAM</font>'
              else if Pos('http://www.idimager.com', '%exif:software') = 1 then
                result := result + '<FONT color="#888888">IDI</font>'
              else
                result := result + '<FONT color="#888888 ">-?-</font> ';

              if ImageItem.isRaw then
                result := result + '</font> <FONT color="#888888">' + WideUpperCase('%FileExtension') + '</font>'
              else
                result := result + '</font> <FONT color="#888888">' + WideUpperCase('%FileExtension') + '</font>';
             
              // add GPS indicator
              if ImageItem.HasGPS then
                result := result + '<FONT color="3300FF"> GPS</font>';
%/code
Second line again, but with a clickable globe icon (which I prefere to use):

Code: Select all

%ImageFileSizeShort  %code
var
  ASoftware: WideString;
begin
  ASoftware := '%xmp:tiff:Software';
  result := ToWideString('');
                 
         // add software ID
              if WideTextPos('Capture', ASoftware) = 1 then
                result := result + '<FONT color="#888888 ">NX2</font>'
              else if WideTextPos('Adobe DNG', ASoftware) <> 0 then
                result := result + '<FONT color="#888888 ">ADC</font>'
              else if WideTextPos('Photoshop', ASoftware) <> 0 then
                result := result + '<FONT color="#888888 ">CS4</font>'
              else if WideTextPos('Bibble', ASoftware) <> 0 then
                result := result + '<FONT color="#888888 ">BIB</font>'
              else if WideTextPos('Ver.1', ASoftware) = 1 then
                result := result + '<FONT color="#888888 ">CAM</font>'
              else if WideTextPos('http://www.idimager.com', ASoftware) = 1 then
                result := result + '<FONT color="#888888">IDI</font>'
              else
                result := result + '<FONT color="#888888 ">-?-</font> ';

              if ImageItem.IsRaw then
                result := result + '</font> <FONT color="#888888">' + WideUpperCase('%FileExtension') + '</font>'
              else
                result := result + '</font> <FONT color="#888888">' + WideUpperCase('%FileExtension') + '</font>';
                 
              // add GPS indicator
              //if ImageItem.HasGPS then
                //result := result + '<FONT color="#3300FF"> GPS</font>';
end;
%/code %GPSExists<a href="event:ShowGEOTag"><img size="22" pathcolor="#4080C0" path="M 370.498,312.759 C 370.498,327.010 365.378,339.176 355.137,349.255 L 355.137,349.255 C 344.896,359.335 332.632,364.375 318.345,364.375 L 318.345,364.375 C 304.058,364.375 291.812,359.416 281.606,349.497 L 281.606,349.497 C 271.294,339.507 266.138,327.386 266.138,313.135 L 266.138,313.135 C 266.138,298.883 271.294,286.745 281.606,276.719 L 281.606,276.719 C 291.812,266.800 304.058,261.841 318.345,261.841 L 318.345,261.841 C 332.632,261.841 344.860,266.729 355.029,276.504 L 355.029,276.504 C 365.342,286.423 370.498,298.507 370.498,312.759 L 370.498,312.759 Z M 367.759,312.437 C 367.759,299.152 362.853,287.765 353.042,278.276 L 353.042,278.276 C 343.302,268.895 331.772,264.204 318.452,264.204 L 318.452,264.204 L 313.081,275.215 L 318.936,276.396 L 323.501,271.831 L 331.558,272.368 L 333.169,276.665 L 328.335,281.499 L 328.335,284.399 L 331.343,284.990 L 332.739,282.734 L 338.057,279.404 L 337.896,281.660 L 339.883,285.098 L 337.520,287.568 L 339.023,289.019 L 335.479,289.233 L 336.929,292.134 L 329.248,295.786 L 330.430,300.137 L 328.013,300.137 L 326.938,295.840 L 321.299,295.732 L 320.278,297.397 L 317.969,296.323 L 314.209,300.083 L 317.217,303.682 L 317.109,307.656 L 320.278,310.020 L 338.755,312.114 L 344.609,316.250 L 343.911,326.509 L 331.182,339.238 C 330.358,340.062 329.552,342.354 328.765,346.113 L 328.765,346.113 C 328.013,349.658 327.744,352.183 327.959,353.687 L 327.959,353.687 L 326.025,355.889 C 324.521,352.917 322.570,348.351 320.171,342.192 L 320.171,342.192 C 319.598,340.080 319.097,337.394 318.667,334.136 L 318.667,334.136 C 318.345,331.450 318.022,328.747 317.700,326.025 L 317.700,326.025 L 309.644,318.936 L 316.787,310.503 L 313.833,306.260 C 309.285,305.329 306.331,304.496 304.971,303.762 L 304.971,303.762 C 303.610,303.028 301.265,300.978 297.935,297.612 L 297.935,297.612 L 300.728,303.037 L 298.848,303.843 L 294.497,295.679 L 295.356,288.052 L 294.014,282.681 L 289.824,278.599 L 286.763,277.847 L 284.077,279.727 L 281.123,280.479 C 272.995,289.860 268.931,300.638 268.931,312.813 L 268.931,312.813 C 268.931,326.419 273.800,337.967 283.540,347.456 L 283.540,347.456 C 293.172,356.838 304.810,361.528 318.452,361.528 L 318.452,361.528 C 332.095,361.528 343.723,356.748 353.337,347.188 L 353.337,347.188 C 362.952,337.627 367.759,326.043 367.759,312.437 L 367.759,312.437 Z "/></a>%GPSExists
Third line:

Code: Select all

%code
            const
              cParentLabelName = 'Personen';   // change the name 'STOCK' to the name of the parent label you'd like to see
              cOnlyFirstLevel  = 0;      // this will show only the first level. Change 1 to 0 for ALL recursive sub levels

            var
              AProp: TCatalogItemProp;
              AProps: TCatalogItemProps;
              ACat: TCatalogPropCategory;
              i: Integer;
              AFound, AFirst: Boolean;
            begin
              result := ToWideString('');

              // add persons
              AProp  := TCatalogItemProp.Create(nil);
              AFound := Catalog.FindPropByName (cParentLabelName, AProp, '', True);
              if not AFound then   
              begin
                // maybe it's a top category?
                ACat := TCatalogPropCategory.Create(nil)
                if Catalog.EnumCategoryNamed (cParentLabelName, ACat) then
                begin
                  AProp.GUID := ACat.GUID;
                  AFound := True;
                end;
                ACat.Free;
              end
              else
                AFound := true;

              if AFound then
              begin
                AProps := TCatalogItemProps.Create (TCatalogItemProp, '');

                  Catalog.EnumPropsForImage (ImageItem, AProps, False, False);
             
                  AFirst := true;
                  for i := 0 to AProps.Count - 1 do
                  begin
                    if (AProps.Items[i].GUID <> AProp.GUID) and
                       (Catalog.PropIsChildOf (AProps.Items[i], AProp.GUID, not cOnlyFirstLevel))
                    then
                    begin
                      result := result + iif(AFirst, '', ',') + AProps.Items[i].PropName;
                      AFirst := false
                    end;
                  end;

                AProps.Free;
              end;

              AProp.Free;
            end;

%/code
PSUServer 5.x, PostgreSQL 10.x
My homepage http://www.michaelweidner.com
PSU Tips and Tricks http://www.michaelweidner.com/WP/psu/

Post Reply