Resource

Resource Basics

Resource Name Export Thumbs and Previews to File
Resource Version 1.1
Category Catalog
Downloads 651
Release Date 10/26/2022 11:58:41 AM
 

Resource Details

Description The script is mainly intended when, after data loss, the thumbs and previews are all what's left.

This script exports previews and/or thumbnails to an output folder. The output files will always be in the JPG format

Installation Instructions 1.1 Exports thumbs, preview, and adjustments (if available)
Usage Instructions 1. Download the script
2. Select the thumbs to export
3. Open the Scripter
4. Load the downloaded script
5. Run the script
Changes in this version na
Special Requirements
 

Author Information

Author Name IDimager Support
 

Script

var
  APro: TxomProgress;
  ADir: WideString;
  i: Integer;
  AImg: TImageItem;
  AMs: TTntMemoryStream;
  AFileName: WideString;
  AHit: Integer;
  AImgHandled: Boolean;
begin
  if Selected.Count = 0 then
  begin
    Say('Select at least on item to export');
    exit;
  end;

  ADir := WindowsMyPicturesDir;
  ADir := ReadFromRegistry('Scripts', 'ExportThumbsPreviews', ADir);
  if not WideSelectDirectory('Select output folder', ADir, ADir) then
    exit;
  ADir := WideIncludeTrailingBackslash(ADir);
  WriteToRegistry('Scripts', 'ExportThumbsPreviews', ADir);

  AHit := 0;
  APro := TxomProgress.Create(nil);
  APro.Max := Selected.Count;

  for i := 0 to Selected.Count - 1 do
  begin
    AImg := Selected.Items[i];
    AImgHandled := False;

    APro.Pos := i + 1;
    APro.ProgressText := AImg.FileNameOnly;


    AMs := TTntMemoryStream.Create;
    try
      AMs.Clear;
      if Thumbnailer.LoadRawPreviewStream(AImg.GUID, AMs) then
      begin
        // thumbs/previews are always JPG formatted
        AFileName := ADir + WideChangeFileExt(AImg.FileNameOnly, '') + '_preview.jpg';
        if not WideFileExists(AFileName) then
        begin
          //Say2(AMs.Size, AFileName);
          AMs.SaveToFile(AFileName);
          AImgHandled := True;
        end;
      end;

      if Thumbnailer.LoadPreviewStream(AImg.GUID, AMs) then
      begin
        // thumbs/previews are always JPG formatted
        AFileName := ADir + WideChangeFileExt(AImg.FileNameOnly, '') + '_adjust.jpg';
        if not WideFileExists(AFileName) then
        begin
          //Say2(AMs.Size, AFileName);
          AMs.SaveToFile(AFileName);
          AImgHandled := True;
        end;
      end;

      AMs.Clear;
      if Thumbnailer.LoadThumbStream(AImg.GUID, AMs) then
      begin
        // thumbs/previews are always JPG formatted
        AFileName := ADir + WideChangeFileExt(AImg.FileNameOnly, '') + '_thumb.jpg';
        if not WideFileExists(AFileName) then
        begin
          //Say2(AMs.Size, AFileName);
          AMs.SaveToFile(AFileName);
          AImgHandled := True;
        end;
      end;

      if AImgHandled then
        AHit := AHit + 1;
    finally
      AMs.Free;
    end;
  end;
  APro.Free;

  Say2(
        'Completed',
        IntToStr(AHit) + ' from the ' + IntToStr(Selected.Count) + ' selected files have been stored.'
      );

end;