Resource

Resource Basics

Resource Name Import ACDSee Metadata
Resource Version 1.0
Category Catalog
Downloads 651
Release Date 1/31/2024 1:27:16 PM
 

Resource Details

Description This script converts ratings, color labels, captions, author, notes, and keywords from ACDSee XMP metadata schema to the industry standard XMP data fields
Installation Instructions Download to the script to your hard drive
Usage Instructions 1. Import images to Photo Supreme
2. Select one or more thumbs
3. Open the Scripter (Tools -> Scripter)
4. Load the downloaded script
5. Run the script
Changes in this version na
Special Requirements
 

Author Information

Author Name IDimager Support
 

Script

{
   Scriptname: Import ACDSee Metadata

   This script converts ratings, color labels, captions, author, notes, and keywords
   from ACDSee XMP metadata schema to the industry standard XMP data fields

   Version: 1.0
   Version Date: 2024-01-31
   Author: IDimager Systems

}

  function ConvertACDSeeXMPtoXMP(AACDXmp, ACatXMP: TXMP): Boolean;
  const
    cOK = True;
  var
    AParam: TMacroParam;
    ALRKeys, ADCKeys: TMacroParam;
    AKey: TMacroParam;
    i, t: Integer;
    ATokens: TTntStringList;
  begin
    result := False;

    // convert rating
    AParam := AACDXmp.FindDesignProperty('http://ns.acdsee.com/iptc/1.0/', 'acdsee:rating');
    if Assigned(AParam) then
    begin
      ACatXMP.QuickSetProperty('http://ns.adobe.com/xap/1.0/', 'xmp:Rating', Nvl(AParam.Content, 0));
      result := cOK;
    end;

    // convert color label
    AParam := AACDXmp.FindDesignProperty('http://ns.adobe.com/xap/1.0/', 'xmp:Label');
    if Assigned(AParam) then
    begin
      ACatXMP.QuickSetProperty('http://ns.adobe.com/xap/1.0/', 'xmp:Label', Nvl(AParam.Content, ''));
      result := cOK;
    end;

    // convert caption to photoshop:Headline
    AParam := AACDXmp.FindDesignProperty('http://ns.acdsee.com/iptc/1.0/', 'acdsee:caption');
    if Assigned(AParam) then
    begin
      ACatXMP.QuickSetProperty('http://ns.adobe.com/photoshop/1.0/', 'photoshop:Headline', Nvl(AParam.Content, ''));
      result := cOK;
    end;

    // convert author to dc:creator
    AParam := AACDXmp.FindDesignProperty('http://ns.acdsee.com/iptc/1.0/', 'acdsee:author');
    if Assigned(AParam) then
    begin
      ACatXMP.QuickSetProperty('http://purl.org/dc/elements/1.1/', 'dc:creator', Nvl(AParam.Content, ''));
      result := cOK;
    end;

    // convert notes to dc:description
    AParam := AACDXmp.FindDesignProperty('http://ns.acdsee.com/iptc/1.0/', 'acdsee:notes');
    if Assigned(AParam) then
    begin
      ACatXMP.QuickSetProperty('http://purl.org/dc/elements/1.1/', 'dc:description', Nvl(AParam.Content, ''));
      result := cOK;
    end;

    // convert keywords to lr:hierarchicalSubject and dc:Subject
    AParam := AACDXmp.FindDesignProperty('http://ns.acdsee.com/iptc/1.0/', 'acdsee:keywords');
    if Assigned(AParam) then
    begin
      ALRKeys := ACatXmp.FindDesignProperty('http://ns.adobe.com/lightroom/1.0/', 'lr:hierarchicalSubject');
      if (ALRKeys = nil) then
        ALRKeys := ACatXmp.AddPropertyToDesign('lr:hierarchicalSubject');

      ADCKeys := ACatXmp.FindDesignProperty('http://purl.org/dc/elements/1.1/', 'dc:subject');
      if (ADCKeys = nil) then
        ADCKeys := ACatXmp.AddPropertyToDesign('dc:subject');

      ALRKeys.ArrayContent.Clear;
      ADCKeys.ArrayContent.Clear;
      for i := 0 to AParam.ArrayContent.Count - 1 do
      begin
        AKey := AParam.ArrayContent.Items[i];
        AKey.CopyTo(ALRKeys.ArrayContent, True);

        // write leaf note to dc:subject
        ATokens := TTntStringList.Create;
        try
          Tokenize(Nvl(AKey.Content, ''), '|', ATokens);
          if ATokens.Count > 0 then
          begin
            ADCKeys.AddArrayElement(ATokens.Strings[ATokens.Count - 1]);
          end;
        finally
          ATokens.Free;
        end;
      end;

      result := cOK;
    end;
  end;

  function ACDSeeXMPFile(AImg: TImageItem): WideString;
  begin
    // ACDSee embedded formats
    if AImg.IsJpeg or
       AImg.IsDng or
       AImg.IsPng or
       WideSameText(WideExtractFileExt(AImg.FileName), 'psd') or
       AImg.IsTif
    then
      result := AImg.FileName
    else
      result := AImg.FileName + '.xmp';
  end;

  procedure HandleImage(AImg: TImageItem);
  var
    AItem: TCatalogItem;
    AXmpFileName: WideString;
    AACDXmp, ACatXMP: TXMP;
    ASl: TTntStringList;
  begin
    AXmpFileName := ACDSeeXMPFile(AImg);

    if not WideFileExists(AXmpFileName) then exit;

    AItem := TCatalogItem.Create(nil);
    AACDXmp := TXMP.Create(False);
    ACatXMP := TXMP.Create(False);
    try
      AACDXmp.Load(AXmpFileName, AImg.FileName, False);

      if not PublicCatalog.FindItemCombinedByGUID(AImg.GUID, AItem) then
        exit;

      PublicCatalog.LoadXMPForItem(AItem, ACatXMP, PublicOptions.CachedXMP);

      if ConvertACDSeeXMPtoXMP(AACDXmp, ACatXMP) then
      begin
        AItem.Rating := Nvl(ACatXmp.QuickGetProperty('http://ns.adobe.com/xap/1.0/', 'xmp:Rating'), 0);
        AItem.ColorLabel := Nvl(ACatXmp.QuickGetProperty('http://ns.adobe.com/xap/1.0/', 'xmp:Label'), '');

        PublicCatalog.StoreItemToDataBase(AItem, False);

        PublicCatalog.SaveXMPForImage(AImg, ACatXMP, PublicOptions.CachedXMP);
        // import the new XMP to the catalog
        PublicCatalog.ReadXMPForImageAdvanced(AImg, PublicOptions.XMPSyncReadSettings, ACatXMP);
      end;
    finally
      ACatXmp.Free;
      AACDXmp.Free;
      AItem.Free;
    end;
  end;

var
  i: Integer;
  AProgress: TxomProgress;
begin
  AProgress := TxomProgress.Create(nil);
  try
    AProgress.Caption := 'Import ACDSee MetaData';
    AProgress.Max := Selected.Count;

    for i := 0 to Selected.Count - 1 do
    begin
      AProgress.ProgressText := Selected.Items[i].FileNameOnly;
      AProgress.Pos := i + 1;

      HandleImage(Selected.Items[i]);
    end;
  finally
    AProgress.Free;
  end;
end;