You've already forked lazarus-ccr
fpexif: Add introductory readme.txt; minor improvements in console_demo. New method TExifData.Save.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6084 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -29,12 +29,16 @@ begin
|
||||
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 ---')
|
||||
if tag <> nil then
|
||||
WriteLn('Shutter speed: ':20, tag.AsString)
|
||||
else
|
||||
WriteLn(tag.AsString);
|
||||
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.';
|
||||
@ -62,6 +66,7 @@ begin
|
||||
imgInfo.Free;
|
||||
end;
|
||||
|
||||
WriteLn;
|
||||
WriteLn('Press ENTER to quit...');
|
||||
ReadLn;
|
||||
|
||||
|
@ -78,6 +78,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure LoadFromFile(const AFileName: String);
|
||||
procedure LoadFromStream(AStream: TStream);
|
||||
procedure Save;
|
||||
procedure SaveToFile(const AFileName: String; AImgFile: String = '');
|
||||
|
||||
function CreateExifData(ABigEndian: Boolean = false): TExifData;
|
||||
@ -562,6 +563,11 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TImgInfo.Save;
|
||||
begin
|
||||
SaveToFile(FFileName);
|
||||
end;
|
||||
|
||||
procedure TImgInfo.SaveToFile(const AFileName: String; AImgFile: String = '');
|
||||
var
|
||||
ms: TMemoryStream;
|
||||
|
110
components/fpexif/readme.txt
Normal file
110
components/fpexif/readme.txt
Normal file
@ -0,0 +1,110 @@
|
||||
================================================================================
|
||||
fpexif
|
||||
================================================================================
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Overview
|
||||
--------------------------------------------------------------------------------
|
||||
fpexif is an fpc/Lazarus library for displaying and manipulating meta data in
|
||||
image files.
|
||||
|
||||
fpexif works without the LCL.
|
||||
|
||||
Meta data systems supported are
|
||||
- EXIF (including thumbnail, GPS, and manufacturer notes (partially) )
|
||||
- IPTC
|
||||
|
||||
Image formats
|
||||
- JPEG
|
||||
- TIFF
|
||||
|
||||
The majority of meta data tags can be modified and written back to file. It
|
||||
should be emphasized, however, that the EXIF maker notes are poorly documented
|
||||
and often become unreadable after editing an EXIF structure.
|
||||
|
||||
Some examples in which fpexif can be applied:
|
||||
- add user comments, keywords and other documentation
|
||||
- fix date/time information (incorrect time/zone at camera when travelling
|
||||
in foreign countries)
|
||||
- adding GPS information to scanned photographs
|
||||
- remember exposure settings of difficult photos
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Quick introduction
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
The basic class is TImgInfo (in unit fpeMetaData). It has properties to read
|
||||
meta data from file/stream (LoadFromFile, LoadFromStream) and to write them
|
||||
back (SaveToFile).
|
||||
|
||||
EXIF data found in the file are stored by the object ExifData from which every
|
||||
tag can be acessed as TagByID[ATagID: TTagID] or TagByName[AName: String].
|
||||
(TTagID is a DWord value containing the numerical ID of a tag in the low-word,
|
||||
and the ID of the "directory" to which the tag belongs in the highword.)
|
||||
|
||||
The properties TagByID and TagByName return a TTag instance in which the tag
|
||||
value is stored. The type of the value depends on the type of the tag and can
|
||||
be accessed by calling AsString, AsInteger, Asfloat, AsIntegerArray,
|
||||
AsFloatArray etc. TTag is declared in unit fpeTags.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Example
|
||||
--------------------------------------------------------------------------------
|
||||
Read meta data from a file, write a particular tag, modify a tag, write back.
|
||||
See also "console_demo".
|
||||
|
||||
uses
|
||||
fpeMetadata, fpeTags;
|
||||
|
||||
var
|
||||
imgInfo: TImgInfo;
|
||||
tag: TTag;
|
||||
begin
|
||||
imgInfo := TImgInfo.Create;
|
||||
try
|
||||
// Read file
|
||||
imgInfo.LoadFromFile('MyImage.jpg');
|
||||
|
||||
// Check for EXIF meta data
|
||||
if imgInfo.HasEXIF then begin
|
||||
|
||||
// Read the shutter speed used when taking an image from EXIF data
|
||||
WriteLn(
|
||||
'ShutterSpeed: ',
|
||||
imgInfo.ExifData.TagByName['ShutterSpeed'].AsString
|
||||
);
|
||||
|
||||
// or better (to avoid the exception if this particular tag does not exist):
|
||||
tag := imgInfo.ExifData.TagByName['ShutterSpeed'];
|
||||
if tag <> nil then WriteLn('ShutterSpeed: ', tag.AsString);
|
||||
|
||||
// Add a user comment to the EXIF data
|
||||
imgInfo.ExifData.TagByName['UserComment'].AsString := 'My best photo';
|
||||
|
||||
// Save the modified meta data to file
|
||||
imgInfo.SaveToFile('MyImage_edited.jpg');
|
||||
// or: imgInfo.Save; // overwrite currently loaded file
|
||||
|
||||
end;
|
||||
finally
|
||||
imgInfo.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Tested systems
|
||||
--------------------------------------------------------------------------------
|
||||
* Lazarus 1.0/fpc 2.6.0 up to Lazarus 1.9/fpc 3.0.4
|
||||
* Delphi 7.0
|
||||
* Delphi XE2
|
||||
* Delphi 10.2 Tokyo
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
License
|
||||
--------------------------------------------------------------------------------
|
||||
Modified LGPL (like Lazarus)
|
||||
|
Reference in New Issue
Block a user