fpexif: Provide option to read exif without maker notes (not standardized and poorly documented feature).

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6091 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2017-12-07 11:35:50 +00:00
parent 824c594816
commit e0d533ac91
5 changed files with 48 additions and 37 deletions

View File

@ -115,18 +115,18 @@ object MainForm: TMainForm
Height = 573
Top = 23
Width = 647
ActivePage = PgImage
ActivePage = PgMetadata
Align = alClient
TabIndex = 1
TabIndex = 0
TabOrder = 1
OnChange = PageControl1Change
object PgMetadata: TTabSheet
Caption = 'Meta data'
ClientHeight = 640
ClientHeight = 545
ClientWidth = 639
object TagListView: TListView
Left = 0
Height = 640
Height = 525
Top = 0
Width = 639
Align = alClient
@ -155,6 +155,31 @@ object MainForm: TMainForm
OnCompare = TagListViewCompare
OnSelectItem = TagListViewSelectItem
end
object Panel1: TPanel
Left = 0
Height = 20
Top = 525
Width = 639
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 20
ClientWidth = 639
TabOrder = 1
object CbDecodeMakerNotes: TCheckBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
Left = 0
Height = 19
Top = 1
Width = 127
Caption = 'Decode MakerNotes'
Checked = True
State = cbChecked
TabOrder = 0
end
end
end
object PgImage: TTabSheet
Caption = 'Image'
@ -162,7 +187,7 @@ object MainForm: TMainForm
ClientWidth = 639
object Image: TImage
Left = 0
Height = 517
Height = 545
Top = 0
Width = 639
Align = alClient
@ -171,40 +196,16 @@ object MainForm: TMainForm
Stretch = True
StretchOutEnabled = False
end
object Panel1: TPanel
Left = 0
Height = 28
Top = 517
Width = 639
Align = alBottom
AutoSize = True
BevelOuter = bvNone
ClientHeight = 28
ClientWidth = 639
TabOrder = 0
Visible = False
object CheckBox1: TCheckBox
AnchorSideLeft.Control = Panel1
AnchorSideTop.Control = Panel1
AnchorSideTop.Side = asrCenter
Left = 0
Height = 19
Top = 5
Width = 127
BorderSpacing.Top = 4
BorderSpacing.Bottom = 4
Caption = 'Decode MakerNotes'
TabOrder = 0
end
end
end
end
object Messages: TMemo
Left = 0
Left = 4
Height = 90
Top = 596
Width = 647
Width = 639
Align = alBottom
BorderSpacing.Left = 4
BorderSpacing.Right = 4
TabOrder = 2
end
object Splitter3: TSplitter

View File

@ -14,7 +14,7 @@ type
{ TMainForm }
TMainForm = class(TForm)
CheckBox1: TCheckBox;
CbDecodeMakerNotes: TCheckBox;
FilenameInfo: TLabel;
Image: TImage;
Messages: TMemo;
@ -114,6 +114,10 @@ begin
FImgInfo := TImgInfo.Create;
try
try
if CbDecodeMakerNotes.Checked then
FImgInfo.MetadataKinds := FImgInfo.MetadataKinds + [mdkExif] - [mdkExifNoMakerNotes]
else
FImgInfo.MetadataKinds := FImgInfo.MetadataKinds - [mdkExif] + [mdkExifNoMakerNotes];
FImgInfo.LoadFromFile(AFileName);
Messages.Hide;
except

View File

@ -411,6 +411,7 @@ begin
Move(AData[0], FExifVersion[1], Length(FExifVersion));
end;
FULLTAG_MAKERNOTE:
if FImgInfo.MetadataKinds * [mdkExif, mdkExifNoMakerNotes] = [mdkExif] then
begin
// The stream is at the end of the makernote data area --> rewind it to start
AStream.Position := AStream.Position - Length(AData);

View File

@ -12,7 +12,12 @@ uses
Classes, SysUtils;
type
TMetaDataKind = (mdkExif, mdkIPTC, mdkComment);
TMetaDataKind = (
mdkExif, // Complete Exif (incl MakerNotes)
mdkExifNoMakerNotes, // Exif without MakerNotes (instead of mdkExif)
mdkIPTC, // IPTC
mdkComment // Comment segment
);
TMetaDataKinds = set of TMetaDataKind;
const

View File

@ -459,7 +459,7 @@ begin
p := AStream.Position;
case marker of
M_EXIF:
if (mdkEXIF in FMetadataKinds) then begin
if FMetaDataKinds * [mdkExif, mdkExifNoMakerNotes] <> [] then begin
reader := TExifReader.Create(self);
try
if not TExifReader(reader).ReadExifHeader(AStream) then
@ -647,7 +647,7 @@ begin
AStream.WriteBuffer(SOI_MARKER, SizeOf(SOI_MARKER));
// No Exif --> write an APP0 segment
if not HasExif or not (mdkExif in FMetadataKinds) then begin
if not HasExif or (FMetadataKinds * [mdkExif, mdkExifNoMakerNotes] = []) then begin
if Length(FHeaderSegment) = 0 then begin
Move(JFIF[1], {%H-}JFIFSegment.Identifier[0], Length(JFIF));
JFIFSegment.JFIFVersion[0] := 1;