ImageEn, unit iexBitmaps

TIOParams.Dict

TIOParams.Dict


Declaration

property Dict: TIEDictionary;


Description

Contains a dictionary of additional properties.

The key "XMP" will contain a sub-dictionary parsed from XMP info.


Demo

Demo  Demos\InputOutput\XMP\XMP.dpr


Examples

// Load an SVG at double size (using ImageMagick plug-in)
ImageEnView1.IO.Params.Dict.Clear();
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Scale', 2 );
ImageEnView1.IO.LoadFromFile( 'D:\SVG\Lion.svg' );

// Load an SVG at size 2000x1000px (using ImageMagick plug-in)
ImageEnView1.IO.Params.Dict.Clear();
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Width', 2000 );
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Height', 1000 );
ImageEnView1.IO.LoadFromFile( 'D:\SVG\Lion.svg' );

// Load an SVG at size up to 2000x1000px, but maintain the aspect ratio (using ImageMagick plug-in)
ImageEnView1.IO.Params.Dict.Clear();
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Width', 2000 );
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Height', 1000 );
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:AspectRatio', 1 );
ImageEnView1.IO.LoadFromFile( 'D:\SVG\Lion.svg' );

// Load an SVG at 200 dpi (using ImageMagick plug-in)
ImageEnView1.IO.Params.Dict.Clear();
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Density', 200 );
ImageEnView1.IO.LoadFromFile( 'D:\SVG\Lion.svg' );

// Save a JPEG as JNG at 95% quality (using ImageMagick plug-in)
ImageEnView1.IO.LoadFromFile( 'D:\Image.jpg' );
ImageEnView1.IO.Params.Dict.Clear();
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick:Quality', 95 );
ImageEnView1.IO.LoadFromFile( 'D:\Image_out.jng' );

// Save a PNG file as a lossless WebP with maximum compression (using ImageMagick plug-in)
ImageEnView1.IO.SaveToFile('D:\Image.png');
ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick', TIEDictionary.Create() );
ImageEnView1.IO.Params.Dict.GetDictionary('ImageMagick').Insert( 'webp:lossless', False );
ImageEnView1.IO.Params.Dict.GetDictionary('ImageMagick').Insert( 'webp:method', 6 );
ImageEnView1.IO.SaveToFile('D:\Image_out.webp');

// Get XMP Document ID
docid := ImageEnView1.IO.Params.Dict.GetString('xapMM:DocumentID', true);

// Output all entries of dc:subject->rdf:Bag of JPEG XMP
{
Example XMP content:

  <dc:subject>
    <rdf:Bag>
       <rdf:li>China</rdf:li>
       <rdf:li>Jan 2008</rdf:li>
       <rdf:li>Shanghai</rdf:li>
    </rdf:Bag>
  </dc:subject>

Output:

  China
  Jan 2008
  Shanghai
}
var
  xmpDict: TIEDictionary;  // Dict containing image XMP data
  navDict: TIEDictionary;  // Dict to navigate XML structure
  list: TObjectList;
  i: integer;
begin
  ImageEnView1.IO.LoadFromFile( 'D:\XMP_Data_202112.JPG' );

  // Get XMP
  xmpDict := ImageEnView1.IO.Params.Dict.GetDictionary('XMP');

  // Output all entries of dc:subject->rdf:Bag into "memo1"
  navDict := xmpDict.GetDictionary('dc:subject', True);
  navDict := navDict.GetDictionary('#content', false);
  navDict := navDict.GetDictionary('rdf:Bag', false);
  navDict := navDict.GetDictionary('#content', false);
  list := navDict.GetList('rdf:li', false);
  for i := 0 to list.Count - 1 do
  begin
    navDict := TIEDictionary(list[i]).GetDictionary('#content', false);
    memo1.lines.add( navDict.GetString('#text', false) );
  end;
end;


// Save a PNG file as a lossless WebP with lossless compression (using ImageMagick plug-in)
var
  imDict: TIEDictionary
begin
  ImageEnView1.IO.LoadFromFile( 'D:\Image.png' );
  imDict := TIEDictionary.Create();
  imDict.Insert( 'webp:lossless', true );
  imDict.Insert( 'webp:method', 0 );
  imDict.Insert( 'webp:auto-filter', true );
  ImageEnView1.IO.Params.Dict.Insert( 'ImageMagick', imDict );
  ImageEnView1.IO.SaveToFile( 'D:\Image_out.webp' );
end;

// List items in "ImageMagick" dictionary
var
  dict: TIEDictionary;
  curr: TIEStrStrEnumerator;
  key, val: String;
begin
  dict := TIEDictionary( ImageEnView1.IO.Params.Dict.Get( 'ImageMagick', True, False ));
  if dict = nil then
    exit;

  curr := TIEStrStrEnumerator.Create();
  try
    while dict.GetNext( curr ) do
    begin
      key := curr.item.key;
      val := IEDictValueToStr( curr.item.value );
      Memo1.Lines.Add( key + '=' + val );
    end;
  finally
    curr.Free();
  end;
end;
{
Result:
webp:method=0
webp:lossless=true
webp:auto-filter=true
}