Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/04/2023 in all areas

  1. Thanks. For others' benefit, here's some code that seems to work to find geotagged pictures that were shot within 100 meters from a reference location: #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <GDIPlus.au3> #include <File.au3> #include <Math.au3> ;https://stackoverflow.com/questions/37484988/distance-formula-between-two-lat-longs-autoit Func _distanceInKm($lat1, $lon1, $lat2, $lon2)     Local $iRadius = 6371     Local $iLat = _Radian($lat2 - $lat1)     Local $iLon = _Radian($lon2- $lon1)     Local $a = Sin($iLat / 2) * Sin($iLat / 2) + Cos(_Radian($lat1)) * Cos(_Radian($lat2)) * Sin($iLon / 2) * Sin($iLon / 2)     Local $c = 2 * ATan2(Sqrt($a), Sqrt(1 - $a))     Local $d = $iRadius * $c     Return Abs($d) EndFunc Func ATan2($y, $x)     Return (2 * ATan($y / ($x + Sqrt($x * $x + $y * $y)))) EndFunc Local Const $REF_LAT = 1.23, $REF_LON = 4.56 Local Const $RADIUS = 100 ; meters Local $distance ; meters ConsoleWrite("Let's get going" & @CRLF) Local $sFileSelectFolder = FileSelectFolder("Select a folder", "") If @error Then Exit MsgBox($MB_SYSTEMMODAL, "", "No folder was selected.") Local $aArray = _FileListToArrayRec($sFileSelectFolder, "*.jpg", $FLTAR_FILES , $FLTAR_RECUR, $FLTAR_NOSORT,$FLTAR_FULLPATH  ) ;_ArrayDisplay($aArray, "JPG") If UBound($aArray) = 0 Then Exit ConsoleWrite("zero elements") ;1D array only _GDIPlus_Startup() Local $filename, $OSM_URL = "https://www.openstreetmap.org/?" For $picindx = 1 to UBound($aArray) -1     $filename = $aArray[$picindx]     Local $hImage = _GDIPlus_ImageLoadFromFile($filename)     If @error Then         _GDIPlus_Shutdown()         ConsoleWrite("An error has occured - unable to load image!  " & $filename)         Exit     EndIf     Local $aPropID = _GDIPlus_ImageGetPropertyIdList($hImage)     ;_ArrayDisplay($aPropID)     Local $aValues, $GpsLatitudeRef, $GpsLongitudeRef     For $i = 1 To $aPropID[0][0]         Switch $aPropID[$i][1]             Case "GpsLatitudeRef"                 $aValues = _GDIPlus_ImageGetPropertyItem($hImage, $aPropID[$i][0])                 If IsArray($aValues) Then                     $GpsLatitudeRef = $aValues[1]                 EndIf             Case "GpsLongitudeRef"                 $aValues = _GDIPlus_ImageGetPropertyItem($hImage, $aPropID[$i][0])                 If IsArray($aValues) Then                     $GpsLongitudeRef = $aValues[1]                 EndIf             Case "GpsLatitude"                 Local $sOutput = ""                 $aValues = _GDIPlus_ImageGetPropertyItem($hImage, $aPropID[$i][0])                 If IsArray($aValues) Then                     For $y = 1 To $aValues[0]                         $sOutput &= $aValues[$y] & "."                     Next                 EndIf ;~                 $sOutput = $aPropID[$i][1] & " = " & $GpsLatitudeRef & " " & StringTrimRight($sOutput, 1) ;~                 ConsoleWrite($sOutput & @CRLF)                 Local $sOutput = ""                 $aValues = _GDIPlus_ImageGetPropertyItem($hImage, $aPropID[$i][0])                 If IsArray($aValues) And $aValues[0] = 3 Then                     Local $GpsLatitude_Decimal                     For $y = 1 To $aValues[0]                         Switch $y                             Case 1                                 $GpsLatitude_Decimal = $aValues[$y]                             Case 2                                 $GpsLatitude_Decimal += ($aValues[$y] / 60)                             Case 3                                 $GpsLatitude_Decimal += ($aValues[$y] / 3600)                         EndSwitch                     Next                 EndIf                 $sOutput = $aPropID[$i][1] & "Decimal = " & $GpsLatitudeRef & " " & $GpsLatitude_Decimal                 ;ConsoleWrite($sOutput & @CRLF & @CRLF)                 ;ConsoleWrite($GpsLatitude_Decimal & ",")             Case "GpsLongitude"                 Local $sOutput = ""                 $aValues = _GDIPlus_ImageGetPropertyItem($hImage, $aPropID[$i][0])                 If IsArray($aValues) Then                     For $y = 1 To $aValues[0]                         $sOutput &= $aValues[$y] & "."                     Next                 EndIf ;~                 $sOutput = $aPropID[$i][1] & " = " & $GpsLongitudeRef & " " & StringTrimRight($sOutput, 1) ;~                 ConsoleWrite($sOutput & @CRLF)                 Local $sOutput = ""                 $aValues = _GDIPlus_ImageGetPropertyItem($hImage, $aPropID[$i][0])                 If IsArray($aValues) And $aValues[0] = 3 Then                     Local $GpsLongitude_Decimal                     For $y = 1 To $aValues[0]                         Switch $y                             Case 1                                 $GpsLongitude_Decimal = $aValues[$y]                             Case 2                                 $GpsLongitude_Decimal += ($aValues[$y] / 60)                             Case 3                                 $GpsLongitude_Decimal += ($aValues[$y] / 3600)                         EndSwitch                     Next                 EndIf                 ;$sOutput = $aPropID[$i][1] & "Decimal = " & $GpsLongitudeRef & " " & $GpsLongitude_Decimal                 $OSM_URL &= StringFormat("mlat=%s&mlon=%s",$GpsLatitude_Decimal,$GpsLongitude_Decimal)                 $distance =Int(1000 * _distanceInKm($REF_LAT, $REF_LON, $GpsLatitude_Decimal, $GpsLongitude_Decimal))                 If $distance <= $RADIUS Then ;picture taken within $RADIUS of reference location?                     ConsoleWrite($filename & @CRLF)                     ConsoleWrite("Distance : " & $distance & @CRLF)                     ConsoleWrite($OSM_URL & @CRLF & @CRLF)                 EndIf                 $OSM_URL = "https://www.openstreetmap.org/?"  ;reset         EndSwitch     Next     _GDIPlus_ImageDispose($hImage) Next _GDIPlus_Shutdown() ConsoleWrite("Done." & @CRLF)
    1 point
  2. Yes it can. To calculate the distance use something like this: https://www.movable-type.co.uk/scripts/latlong.html #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <GDIPlus.au3> #include <File.au3> ;NO GPS #include "image_get_info.au3" ;https://www.autoitscript.com/forum/topic/13096-udf-imagegetinfo/ #include <GDIPlus.au3> _GDIPlus_Startup() Local $hImage = _GDIPlus_ImageLoadFromFile("test.jpg") If @error Then _GDIPlus_Shutdown() ConsoleWrite("An error has occured - unable to load image!") Exit EndIf Local $aPropID = _GDIPlus_ImageGetPropertyIdList($hImage) ;_ArrayDisplay($aPropID) Local $aValues, $GpsLatitudeRef, $GpsLongitudeRef For $i = 1 To $aPropID[0][0] ;GPSLatitude + GPSLongitude? Switch $aPropID[$i][1] Case "GpsLatitudeRef" $aValues = _GDIPlus_ImageGetPropertyItem($hImage, $aPropID[$i][0]) If IsArray($aValues) Then $GpsLatitudeRef = $aValues[1] EndIf Case "GpsLongitudeRef" $aValues = _GDIPlus_ImageGetPropertyItem($hImage, $aPropID[$i][0]) If IsArray($aValues) Then $GpsLongitudeRef = $aValues[1] EndIf Case "GpsLatitude" Local $sOutput = "" $aValues = _GDIPlus_ImageGetPropertyItem($hImage, $aPropID[$i][0]) If IsArray($aValues) Then For $y = 1 To $aValues[0] $sOutput &= $aValues[$y] & "." Next EndIf $sOutput = $aPropID[$i][1] & " = " & $GpsLatitudeRef & " " & StringTrimRight($sOutput, 1) ConsoleWrite($sOutput & @CRLF) Local $sOutput = "" $aValues = _GDIPlus_ImageGetPropertyItem($hImage, $aPropID[$i][0]) If IsArray($aValues) And $aValues[0] = 3 Then Local $GpsLatitude_Decimal For $y = 1 To $aValues[0] Switch $y Case 1 $GpsLatitude_Decimal = $aValues[$y] Case 2 $GpsLatitude_Decimal += ($aValues[$y] / 60) Case 3 $GpsLatitude_Decimal += ($aValues[$y] / 3600) EndSwitch Next EndIf $sOutput = $aPropID[$i][1] & "Decimal = " & $GpsLatitudeRef & " " & $GpsLatitude_Decimal ConsoleWrite($sOutput & @CRLF & @CRLF) Case "GpsLongitude" Local $sOutput = "" $aValues = _GDIPlus_ImageGetPropertyItem($hImage, $aPropID[$i][0]) If IsArray($aValues) Then For $y = 1 To $aValues[0] $sOutput &= $aValues[$y] & "." Next EndIf $sOutput = $aPropID[$i][1] & " = " & $GpsLongitudeRef & " " & StringTrimRight($sOutput, 1) ConsoleWrite($sOutput & @CRLF) Local $sOutput = "" $aValues = _GDIPlus_ImageGetPropertyItem($hImage, $aPropID[$i][0]) If IsArray($aValues) And $aValues[0] = 3 Then Local $GpsLongitude_Decimal For $y = 1 To $aValues[0] Switch $y Case 1 $GpsLongitude_Decimal = $aValues[$y] Case 2 $GpsLongitude_Decimal += ($aValues[$y] / 60) Case 3 $GpsLongitude_Decimal += ($aValues[$y] / 3600) EndSwitch Next EndIf $sOutput = $aPropID[$i][1] & "Decimal = " & $GpsLongitudeRef & " " & $GpsLongitude_Decimal ConsoleWrite($sOutput & @CRLF & @CRLF) EndSwitch Next _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown()
    1 point
  3. Andreik

    Try...Catch Block

    You are just... 17 years later.
    1 point
×
×
  • Create New...