How to read GPS Coordinates from JPG EXIF using CCR.EXIF in Delphi?

前端 未结 3 1244
余生分开走
余生分开走 2021-01-20 02:32

It\'s quite easy setting the GPS coordinates using the GPSLatitude and GPSLatitude properties Assign method, but reading the coords has me stumped. I\'ve trying to access th

3条回答
  •  感情败类
    2021-01-20 03:11

    Looking in depth at the source, it seems one can use the "Quotient" property. In stead of storing the decimal float, the developer chose to store the components Numerator, Denominator and Quotient.

    I don't think it's how it's meant to be used, but it's working! Thanks for everyone's time.

    So, to read the GPS Coordinates from a JPG file using CCR.EXIF, I do the following:

    var
        imgJpg: TJpegImageEx;
        d,m,s,lat: real;
    
    imgJpg.LoadFromFile(FolderName+'\'+SR.Name); {Load the particular JPG File }
    d:= imgJpg.ExifData.GPSLatitude.Degrees.Quotient; {Degrees}
    m:= imgJpg.ExifData.GPSLatitude.Minutes.Quotient; {Minutes}
    s:= imgJpg.ExifData.GPSLatitude.Seconds.Quotient; {Seconds}
    
    {Now determine the sign}
    if imgJpg.ExifData.GPSLatitude.Direction=ltNorth then
      ref:= 1
    else
      ref:= -1;
    
    {Convert to decimal}
    lat:= ref*(d+(m/60)+(s/60/60));
    

    lat now contains the latitude. Same can be done for long of course.

提交回复
热议问题