ImageEn, unit iexMetaHelpers

TIOParamsHelper.WriteTo

TIOParamsHelper.WriteTo


Declaration

function WriteTo(Dest: TObject; MetaType: TIEMetaType; ExifTagTypes: TIEExifInclude = []; DicomTagTypes: TIEDicomInclude = []; SkipBlank: Boolean = False): Boolean; overload;
procedure WriteTo(const Filename: string; MetaType: TIEMetaType; ExifTagTypes: TIEExifInclude = []; DicomTagTypes: TIEDicomInclude = []; SkipBlank: Boolean = False); overload;


Description

Fills a TListView, TStringGrid or TStrings object with the meta-data values. Alternatively, you can export to a text or CSV file.
The left column will contain field names (e.g. using EXIF_FieldDescription or IEGetDicomTagDescription) and the right column the values (e.g. using GetTagString for DICOM or GetString for XMP).
Value Description
Dest A TListView, TStringGrid or TStrings object (it will be cleared and formatted)
Filename Full path to new file with a .txt or .csv extension (if the file already exists it will be overwritten)
MetaType What type of meta-data to output, e.g. iemExif
ExifTagTypes If MetaType is iemExif, specify which Exif tag types to output, or [] for all
DicomTagTypes If MetaType is iemDicom, specify which Dicom tag types to output, or [] for all
SkipBlank Whether fields without a value are included or not

Result is true if the image has any relevant data.



To update the params after user editing, use ReadFrom
You can also use the in-built meta-data control, TIEMetaListView.

TStringGrid Notes
If the TStringGrid does not have any existing columns, two columns will be added. If the grid has a fixed row it will be given a heading of "Name" and "Value".

TListView Notes
If the TListView does not have any existing columns, two columns will be added and the ViewStyle set to vsReport.

Note:
 When saving to a file, the file extension must be .txt or .csv. An exception will be raised if there is no valid data to output or the format is invalid. CSV format outputs all fields, whereas text only outputs fields with a value.
 For iemXMP, only common XMP fields are added. Unknown XMP tags are skipped
 WriteTo is a Helper method. You must add iexMetaHelpers to your uses clause to access it
 Delphi/C++ 2005 or newer is required


Demos

Demo  Demos\InputOutput\Dicom\Dicom.dpr
Demo  Demos\InputOutput\Exif\Exif.dpr
Demo  Demos\InputOutput\Iptc\Iptc.dpr
Demo  Demos\InputOutput\XMP\XMP.dpr


Examples

// Output the EXIF properties of the current image to a TMemo in the format: Caption: Value
ImageEnView1.IO.Params.WriteTo( memo1.Lines, iemEXIF );

// Output the Dicom properties of the current image to a TListView (all types)
ImageEnView1.IO.WriteTo( ListView1, iemDicom, [], [ diStandard, diChildTags, diProprietary, diDeprecated, diUnknown ] );

// Export the dicom list of the current image to a file (exclude deprecated and unknown tags)
ImageEnView1.IO.Params.WriteTo( 'D:\DicomList.txt', iemDicom, [], [ diStandard, diChildTags, diProprietary ] );

// Copy general file information (filename, size, date, dimensions, etc) to the clipboard
ss := TStringList.create;
ImageEnView1.IO.Params.WriteTo( ss, iemGeneral );
Clipboard.AsText := ss.Text;
ss.Free;

// Display the EXIF properties of a file in a TStringGrid
io := TImageEnIO.Create(nil);
io.ParamsFromFile( 'D:\image.jpeg' );
StringGrid1.Options := Options - [goEditing];
io.Params.WriteTo( StringGrid1 );
io.Free;

// Save common and camera EXIF tags to a CSV file
ImageEnView1.IO.Params.WriteTo( 'D:\ImageInfo.csv', iemEXIF, [ efCommon, efCamera ]);

// Save XMP tags to a text file skipping any blank fields
ImageEnView1.IO.Params.WriteTo( 'D:\ImageInfo.txt', iemXMP, [], [], TRUE );

Compatibility Notes
WriteTo replaces the following deprecated methods:
Old Method Old Code Example New Code Example
ReadGridFromEXIF StringGrid1.ReadGridFromEXIF( ImageEnView1.IO.Params ); ImageEnView1.IO.Params.WriteTo( StringGrid1, iemEXIF );
ReadListFromEXIF ListView1.ReadListFromEXIF( ImageEnView1.IO.Params ); ImageEnView1.IO.Params.WriteTo( ListView1, iemEXIF );
EXIF_WriteToStrings ImageEnView1.IO.Params.EXIF_WriteToStrings( memTags.Lines ); ImageEnView1.IO.Params.WriteTo( memTags.Lines, iemEXIF );
ReadGridFromIPTC StringGrid1.ReadGridFromIPTC( ImageEnView1.IO.Params ); ImageEnView1.IO.Params.WriteTo( StringGrid1, iemIPTC );
ReadListFromIPTC ListView1.ReadListFromIPTC( ImageEnView1.IO.Params ); ImageEnView1.IO.Params.WriteTo( ListView1, iemIPTC );
IPTC_WriteToStrings ImageEnView1.IO.Params.IPTC_WriteToStrings( memTags.Lines ); ImageEnView1.IO.Params.WriteTo( memTags.Lines, iemIPTC );
ReadGridFromDicom StringGrid1.ReadGridFromDicom( ImageEnView1.IO.Params, [ diProprietary, diChildTags ]); ImageEnView1.IO.Params.WriteTo( StringGrid1, iemDICOM, [], [ diProprietary, diChildTags ]);
DICOM_WriteToStrings ImageEnView1.IO.Params.DICOM_WriteToStrings( memTags.Lines, [ diProprietary, diChildTags ]); ImageEnView1.IO.Params.WriteTo( memTags.Lines, [], iemDICOM, [ diProprietary, diChildTags ]);
ReadGridFromXMP StringGrid1.ReadGridFromXMP( ImageEnView1.IO.Params ); ImageEnView1.IO.Params.WriteTo( StringGrid1, iemXMP );
ReadListFromXMP ListView1.ReadListFromXMP( ImageEnView1.IO.Params ); ImageEnView1.IO.Params.WriteTo( ListView1, iemXMP );
XMP_WriteToStrings ImageEnView1.IO.Params.XMP_WriteToStrings( memTags.Lines ); ImageEnView1.IO.Params.WriteTo( memTags.Lines, iemXMP );