You've already forked lazarus-ccr
fpexif: Add AddOrReplaceTagByID and ..ByName methods to TExifData.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8773 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -95,6 +95,8 @@ type
|
|||||||
AData: TBytes; ACount: Integer; ALkupTbl: String = ''): Integer;
|
AData: TBytes; ACount: Integer; ALkupTbl: String = ''): Integer;
|
||||||
|
|
||||||
function AddOrReplaceTag(ATag: TTag): Integer;
|
function AddOrReplaceTag(ATag: TTag): Integer;
|
||||||
|
function AddOrReplaceTagByID(ATagID: TTagID): TTag;
|
||||||
|
function AddOrReplaceTagByName(AFullTagName: String): TTag;
|
||||||
function AddTag(ATag: TTag): Integer;
|
function AddTag(ATag: TTag): Integer;
|
||||||
function AddTagByID(ATagID: TTagID): TTag;
|
function AddTagByID(ATagID: TTagID): TTag;
|
||||||
function AddTagByName(AFullTagName: String): TTag;
|
function AddTagByName(AFullTagName: String): TTag;
|
||||||
@ -640,6 +642,28 @@ begin
|
|||||||
Result := AddTag(ATag);
|
Result := AddTag(ATag);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TExifData.AddOrReplaceTagByID(ATagID: TTagID): TTag;
|
||||||
|
var
|
||||||
|
idx: Integer;
|
||||||
|
begin
|
||||||
|
idx := IndexOfTagID(ATagID);
|
||||||
|
if idx = -1 then
|
||||||
|
Result := AddTagByID(ATagID)
|
||||||
|
else
|
||||||
|
Result := FTagList[idx];
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TExifData.AddOrReplaceTagByName(AFullTagName: String): TTag;
|
||||||
|
var
|
||||||
|
idx: Integer;
|
||||||
|
begin
|
||||||
|
idx := IndexOfTagName(AFullTagName);
|
||||||
|
if idx = -1 then
|
||||||
|
Result := AddTagByName(AFullTagName)
|
||||||
|
else
|
||||||
|
Result := FTagList[idx];
|
||||||
|
end;
|
||||||
|
|
||||||
function TExifData.AddTag(ATag: TTag): Integer;
|
function TExifData.AddTag(ATag: TTag): Integer;
|
||||||
var
|
var
|
||||||
parentID: TTagID;
|
parentID: TTagID;
|
||||||
|
@ -345,6 +345,10 @@ begin
|
|||||||
CheckTrue(lTag <> nil, 'Tag "ExifImageHeight" not found for writing');
|
CheckTrue(lTag <> nil, 'Tag "ExifImageHeight" not found for writing');
|
||||||
lTag.AsInteger := 267;
|
lTag.AsInteger := 267;
|
||||||
|
|
||||||
|
lTag := imgInfo.ExifData.AddTagByName('EXIF.Artist');
|
||||||
|
Checktrue(lTag <> nil, 'Tag "EXIF.Artist" not found for writing');
|
||||||
|
lTag.AsString := 'fpexif-artist';
|
||||||
|
|
||||||
// Save to file;
|
// Save to file;
|
||||||
// Takes the image data from WorkFile_WithExif, replaces its EXIF with the
|
// Takes the image data from WorkFile_WithExif, replaces its EXIF with the
|
||||||
// current EXIF structure and writes to WorkFile_NoExif.
|
// current EXIF structure and writes to WorkFile_NoExif.
|
||||||
@ -422,6 +426,10 @@ begin
|
|||||||
CheckTrue(lTag <> nil, 'Tag "ExifImageHeight" not found');
|
CheckTrue(lTag <> nil, 'Tag "ExifImageHeight" not found');
|
||||||
CheckEquals(267, lTag.AsInteger, 'Value mismatch of tag "ExifImageHeight"');
|
CheckEquals(267, lTag.AsInteger, 'Value mismatch of tag "ExifImageHeight"');
|
||||||
|
|
||||||
|
lTag := ImgInfo.ExifData.TagByName['EXIF.Artist'];
|
||||||
|
CheckTrue(lTag <> nil, 'Tag "EXIF.Artist" not found');
|
||||||
|
CheckEquals('fpexif-artist', lTag.AsString, 'Value mismatch of tag "EXIF.Artist"');
|
||||||
|
|
||||||
// No thumbnail in dest file!
|
// No thumbnail in dest file!
|
||||||
|
|
||||||
finally
|
finally
|
||||||
|
@ -496,6 +496,10 @@ begin
|
|||||||
CheckTrue(lTag <> nil, 'Tag "ExifImageHeight" not found for writing');
|
CheckTrue(lTag <> nil, 'Tag "ExifImageHeight" not found for writing');
|
||||||
lTag.AsInteger := 150;
|
lTag.AsInteger := 150;
|
||||||
|
|
||||||
|
lTag := imgInfo.ExifData.AddTagByName('EXIF.Artist');
|
||||||
|
Checktrue(lTag <> nil, 'Tag "EXIF.Artist" not found for writing');
|
||||||
|
lTag.AsString := 'fpexif-artist';
|
||||||
|
|
||||||
// Save to file;
|
// Save to file;
|
||||||
// Takes the image data from WorkFile_WithExif, replaces its EXIF with the
|
// Takes the image data from WorkFile_WithExif, replaces its EXIF with the
|
||||||
// current EXIF structure and writes to WorkFile_NoExif.
|
// current EXIF structure and writes to WorkFile_NoExif.
|
||||||
@ -558,6 +562,10 @@ begin
|
|||||||
CheckTrue(lTag <> nil, 'Tag "ExifImageHeight" not found for reading');
|
CheckTrue(lTag <> nil, 'Tag "ExifImageHeight" not found for reading');
|
||||||
CheckEquals('150', lTag.AsString, 'Value mismatch of tag "ExifImageHeight"');
|
CheckEquals('150', lTag.AsString, 'Value mismatch of tag "ExifImageHeight"');
|
||||||
|
|
||||||
|
lTag := ImgInfo.ExifData.TagByName['EXIF.Artist'];
|
||||||
|
CheckTrue(lTag <> nil, 'Tag "EXIF.Artist" not found');
|
||||||
|
CheckEquals('fpexif-artist', lTag.AsString, 'Value mismatch of tag "EXIF.Artist"');
|
||||||
|
|
||||||
finally
|
finally
|
||||||
imgInfo.Free;
|
imgInfo.Free;
|
||||||
end;
|
end;
|
||||||
|
Reference in New Issue
Block a user