2004.11.14 19:05 "[Tiff] Libtiff in Delphi", by Lars-Göran Edholm

2004.11.16 10:31 "Re: [Tiff] Libtiff in Delphi", by Joris Van Damme

I'm trying to read Tiff tags in Delphi 7 but with no luck:

It's usefull to mention you are using LibTiffDelphi (http://www.awaresystems.be/imaging/tiff/delphi.html), because there are also LibTiff DLL's around that could be used in Delphi, and some issues probably are handled differently with those.

var
han:PTIFF;
begin
if OpenDialog1.Execute then
try
han:=TIFFOpen(OpenDialog1.FileName,'r');
showmessage(inttostr(TIFFGetField(han, TIFFTAG_IMAGEWIDTH)));
 except
 end;
  TIFFClose(han);
 end;

Two mistakes here:

So your code should be (unchecked, from the top of my head):

var
  han: PTIFF;
  m: Cardinal;
begin
  if OpenDialog1.Execute then
  begin
    han:=TIFFOpen(OpenDialog1.Filename,'r');
    if han=nil then ... {respond to the error here}
    if TIFFGetField(han, TIFFTAG_IMAGEWIDTH,@m)=0 then... {respond to the error here}
    {m is now your image width}
  end;
end;

Joris Van Damme
info@awaresystems.be
http://www.awaresystems.be
Download your free TIFF tag viewer for windows here:
http://www.awaresystems.be/imaging/tiff/astifftagviewer.html