Open GoogleCodeExporter opened 9 years ago
Hi Chris,
it's been a while, now i found a way to read DPI from image.
In App13 marker there is the Photoshop resolution tag, see
http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Photoshop.html
This is my code:
AStream.Seek(0, soFromBeginning);
for Segment in JPEGHeader(AStream) do
case Segment.MarkerNum of
..
jmApp13:
begin
AdobeEnumerator:= Segment.GetEnumerator;
while Assigned(AdobeEnumerator) and AdobeEnumerator.MoveNext do
begin
AdobeResourceBlock:= AdobeEnumerator.Current;
// $3ED is Photoshop resolution tag, see http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Photoshop.html
if (AdobeResourceBlock.Signature = '8BIM') and (AdobeResourceBlock.TypeID = $3ED) then
begin
ResolutionStream:= AdobeResourceBlock.Data;
if Assigned(ResolutionStream) and (ResolutionStream.Size >= 14) then
begin
ResolutionStream.Position:= 0;
ResolutionStream.Read(XRes, SizeOf(Integer));
XRes:= Swap(XRes);
ResolutionStream.Read(ResolutionUnit, SizeOf(Word));
ResolutionUnit:= Swap(ResolutionUnit);
// 1 = inch, 2 = cm
if ResolutionUnit = 2 then
XRes:= Round(XRes * 2.54);
// 2 Bytes padding?
ResolutionStream.Position:= ResolutionStream.Position + 2;
ResolutionStream.Read(YRes, SizeOf(Integer));
YRes:= Swap(YRes);
ResolutionStream.Read(ResolutionUnit, SizeOf(Word));
ResolutionUnit:= Swap(ResolutionUnit);
// 1 = inch, 2 = cm
if ResolutionUnit = 2 then
YRes:= Round(YRes * 2.54);
end;
end;
end;
end; // end case
Maybe there is a better way like wrapping up in class? Is it possible that you
integrate it into CCR.EXIF classes?
Thanks and best regards
Dirk Carstensen
Original comment by dirk.car...@gmail.com
on 27 May 2014 at 2:25
Original issue reported on code.google.com by
dirk.car...@gmail.com
on 4 Nov 2013 at 9:01Attachments: