2015-11-05 55 views

回答

0

你可以使用一個修改版本的代碼段下面的二進制輸出轉換在camera.getImagejpg文件。

def getImage(fileUri): 
    url = request("commands/execute") 
    body = json.dumps({"name": "camera.getImage", 
     "parameters": { 
      "fileUri": fileUri, 
      "_type": "image" 
     } 
     }) 
    with open('output.jpg', 'wb') as handle: 
     response = requests.post(url, data=body, stream=True) 
     for block in response.iter_content(1024): 
      handle.write(block) 
+0

我會這樣做,但從我看到的處理二進制數據的部分是一個後...與它是一個正常的文件寫,除了流屬性,我不認爲有一個等效javscript – user2030809

+0

我讀至今對那一個應該使用的功能之一是BTOA但是,如果我嘗試在我的二進制代碼我得到一個錯誤,告訴我,它包含Latin1的之外的字符......這意味着輸出是一個unicode字符串...我真的不知道如何編寫一個文件...我在PhoneGap的順便說一句這樣的應用程序 – user2030809

相關問題