downloadImage url = unsafePerformIO $ downloadImage' url
    where downloadImage' url = do let (_, name,fload,fsave) = getImageFunctionNameType url
                                  (cod,img) <- curlGetString_ url []
                                  putStrLn $ show cod ++ " at " ++ url
                                  gdimg <- fload img
                                  (w,h) <- imageSize gdimg
                                  tmpDir <- retrieveTempDir
                                  let path = tmpDir </> name
                                  fsave path gdimg
                                  putStrLn $ "image saved at " ++ path
                                  return (w,h)
downloadImage url = unsafePerformIO $ downloadImage' url
    where downloadImage' url = do let (_, name,fload,fsave) = getImageFunctionNameType url
                                  (cod,img) <- curlGetString_ url []
                                  putStrLn $ show cod ++ " at " ++ url
                                  gdimg <- fload img
                                  (w,h) <- imageSize gdimg
                                  tmpDir <- retrieveTempDir
                                  let path = tmpDir </> name
                                  fsave path gdimg
                                  putStrLn $ "image saved at " ++ path
                                  return (w,h)
downloadImage url = unsafePerformIO $ downloadImage' url
    where downloadImage' url = do let (_, name,fload,fsave) = getImageFunctionNameType url
                                  (cod,img) <- curlGetString_ url []
                                  putStrLn $ show cod ++ " at " ++ url
                                  gdimg <- fload img
                                  (w,h) <- imageSize gdimg
                                  tmpDir <- retrieveTempDir
                                  let path = tmpDir </> name
                                  fsave path gdimg
                                  putStrLn $ "image saved at " ++ path
                                  return (w,h)