Created
November 16, 2014 19:23
-
-
Save ehamberg/3604aa4f2aa4984ef48f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE LambdaCase #-} | |
import Graphics.HsExif (parseFileExif, getGpsLatitudeLongitude) | |
import System.Environment (getArgs) | |
import System.FilePath (takeFileName) | |
import System.IO (hPutStrLn, stderr) | |
import Data.List (intercalate) | |
printGeoLine :: FilePath -> IO () | |
printGeoLine filename = do | |
parseFileExif filename >>= \case | |
Left e -> hPutStrLn stderr $ "Couldn't parse exif data from " ++ filename | |
Right exifData -> case getGpsLatitudeLongitude exifData of | |
Just (lat, long) -> printCsvLine [show lat, show long, takeFileName filename] | |
Nothing -> hPutStrLn stderr $ "No geo data for " ++ filename | |
where printCsvLine = putStrLn . intercalate "\t" | |
main :: IO () | |
main = getArgs >>= mapM_ printGeoLine |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment