2017-11-17 159 views
-3

我安裝了DEXIF包,能夠讀取一些EXIF條目。但不是文檔中描述的計算值。 以下代碼顯示了什麼可行。對於註釋行我得到的錯誤:標識符idents沒有成員「focalLenght」等。 我怎樣才能得到這些和更多的領域?DExif-Package中某些字段的Compliererror

procedure TForm1.EXIFAnzeigen(filename: string); 
var 
    ImgData: TImgData; 
    i :integer; 
begin 
    //EDitor leeren 

    ValueListEditor1.Strings.Clear; 
    if FileExists(filename) then begin 
    ImgData:= TImgData.Create(); 
    ImgData.Tracelevel :=1; 
    try 
     if uppercase(ExtractFileExt(filename)) = '.JPG' then begin 
      if ImgData.ProcessFile(filename) then begin 
       if ImgData.HasEXIF then begin 
       ValueListEditor1.InsertRow('Camera Make', 
       ImgData.ExifObj.CameraMake,True); 
       ValueListEditor1.InsertRow('Camera Modell', 
       ImgData.ExifObj.CameraModel,True); 
       ValueListEditor1.InsertRow('Picture DateTime', 
       FormatDateTime(ISO_DATETIME_FORMAT, ImgData.ExifObj.GetImgDateTime),True); 
       ValueListEditor1.InsertRow('Width', 
       inttostr(ImgData.ExifObj.Width),True); 
       ValueListEditor1.InsertRow('FlashUsed', 
       intToStr(ImgData.ExifObj.FlashUsed),True); 

//    ValueListEditor1.InsertRow('FocalLength', 
//    inttostr(ImgData.ExifObj.FocalLength),True); 
//    ValueListEditor1.InsertRow('ApertureFNumber', 
//    ImgData.ExifObj.ApertureFNumber,True); 
//    ValueListEditor1.InsertRow('ExposureTime', 
//    ImgData.ExifObj.ExposureTime,True); 
//    ValueListEditor1.InsertRow('Distance', 
//    ImgData.ExifObj.Distance,True); 
//    ValueListEditor1.InsertRow('Process', 
//    ImgData.ExifObj.Process,True); 
       end else begin 
        ValueListEditor1.InsertRow('No EXIF','No Data',True); 
       end; 
      end else begin 
       ValueListEditor1.InsertRow('No EXIF','Processdata',True); 
      end; 
     end else begin 
      ValueListEditor1.Strings.Clear; 
     end; 
    finally 
     ImgData.Free; 
    end; 
    end; 
end; 
+0

你有沒有嘗試閱讀源代碼以查看哪些屬性可用以及何時(以及如何)使用它們? –

+0

我確實在搜索代碼,但沒有在任何地方找到'FocalLenght'。只需閱讀文檔。 – ratmalwer

+0

嗯,它不是'FocalLenght',它是'FocalLength',如果你按照你在文章和最後評論中拼寫的方式來搜索它,你顯然不會找到它。如果您爲搜索拼寫正確,但沒有找到它,則不在此處。 –

回答

2

documentation說:

Some of the more common fields are accessible as properties of the EXIFObj of the ImgData.

,並給出了一個例子讀這些屬性,部分和你一樣成功與您的代碼閱讀。

FocalLength,並在你的代碼失敗的人,已經用另一種方法爲文檔進行訪問說:

Other EXIF field can be read by using the property TagValue and specifying the name of the EXIF property

下面的例子闡明:

ValueListEditor1.InsertRow('FocalLength', 
inttostr(ImgData.ExifObj.TagValue['FocalLength']),True); 
+0

謝謝..幫助!我可以用這種方法訪問更多的標籤。但是我不得不更深入一些標籤名稱,因爲我沒有找到我期望的標籤名稱。在網上找到這個列表:http://www.exiv2.org/tags.html但我必須檢查名稱是否符合DEXIF及其結果。 – ratmalwer

+0

當然,更好地堅持'dEXIF'中的名稱或根據需要添加可能的新名稱。這是一個完全不同的話題。在每個項目之前添加一個檢查,如'If ImgData.ExifObj.TagValue ['FocalLength'] <> null then',以避免錯誤 –

+0

好主意如果我有能力給DEXIF添加名字......我現在就來看看我更瞭解它。週末愉快 !!! – ratmalwer