fpexif: Add Delphi examples

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7328 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-02-17 23:17:39 +00:00
parent 9779c4beba
commit acb60ffd33
14 changed files with 2688 additions and 0 deletions

View File

@ -0,0 +1,74 @@
program console_demo;
{$mode objfpc}{$H+}
uses
Classes,
fpeMetaData, fpeTags;
var
imgInfo: TImgInfo;
tag: TTag;
begin
imgInfo := TImgInfo.Create;
try
// Read file
imgInfo.LoadFromFile('..\test-image.jpg');
// Check for EXIF
if imgInfo.HasExif then begin
// Write out some tags
// (1) date and time when the picture was taken
Write('Date/time: ':20);
tag := imgInfo.ExifData.TagByName['DateTime'];
if tag = nil then
WriteLn('--- not available in this file ---')
else
WriteLn(tag.AsString);
// (2) shutter speed used when taking the photo
tag := imgInfo.ExifData.TagByName['ShutterSpeed'];
if tag <> nil then
WriteLn('Shutter speed: ':20, tag.AsString)
else
begin
// (3) Sometimes alternative tags are availabe
tag := imgInfo.ExifData.TagByName['ExposureTime'];
if tag <> nil then
WriteLn('Exposure time: ':20, tag.AsString);
end;
// Add user comment
imgInfo.ExifData.TagByName['UserComment'].AsString := 'This is my favorite photo.';
// Save to file
imgInfo.SaveToFile('edited_image.jpg');
end
else
WriteLn('No EXIF data in this file.');
// Check for IPTC
if imgInfo.HasIPTC then begin
// Write out IPTC key words
Write('Keywords: ':20);
tag := imgInfo.IptcData.TagByName['Keywords'];
if tag = nil then
WriteLn('--- not available in this file ---')
else
WriteLn(tag.AsString);
end
else
WriteLn('No IPTC data in this file.');
finally
imgInfo.Free;
end;
WriteLn;
WriteLn('Press ENTER to quit...');
ReadLn;
end.