fpexif: Add very simple console demo

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6083 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-12-02 22:05:55 +00:00
parent 3813bcca82
commit a46eb1788d
3 changed files with 134 additions and 0 deletions

View File

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="10"/>
<PathDelim Value="\"/>
<General>
<Flags>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
<MainUnitHasScaledStatement Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="console_demo"/>
<UseAppBundle Value="False"/>
<ResourceType Value="res"/>
</General>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="fpexif_pkg"/>
</Item1>
</RequiredPackages>
<Units Count="1">
<Unit0>
<Filename Value="console_demo.pas"/>
<IsPartOfProject Value="True"/>
</Unit0>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="console_demo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,69 @@
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
Write('Shutter speed: ':20);
tag := imgInfo.ExifData.TagByName['ShutterSpeed'];
if tag = nil then
WriteLn('--- not available in this file ---')
else
WriteLn(tag.AsString);
// 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('Press ENTER to quit...');
ReadLn;
end.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB