diff --git a/components/fpexif/examples/console_demo/console_demo.lpi b/components/fpexif/examples/console_demo/console_demo.lpi new file mode 100644 index 000000000..f89acd0f9 --- /dev/null +++ b/components/fpexif/examples/console_demo/console_demo.lpi @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + <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> diff --git a/components/fpexif/examples/console_demo/console_demo.pas b/components/fpexif/examples/console_demo/console_demo.pas new file mode 100644 index 000000000..1e6784a2b --- /dev/null +++ b/components/fpexif/examples/console_demo/console_demo.pas @@ -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. + diff --git a/components/fpexif/examples/test-image.jpg b/components/fpexif/examples/test-image.jpg new file mode 100644 index 000000000..cec694dad Binary files /dev/null and b/components/fpexif/examples/test-image.jpg differ