![](/img/trans.png)
[英]AttributeError: 'bytes' object has no attribute 'tell'
我正在使用email.message和smtplib發送使用 python 的電子郵件。當圖像作為附件發送時,它會引發此錯誤: 這是圖像附件的代碼: ...
[英]AttributeError: 'bytes' object has no attribute 'tell'
我正在使用email.message和smtplib發送使用 python 的電子郵件。當圖像作為附件發送時,它會引發此錯誤: 這是圖像附件的代碼: ...
[英]How to extract base64 extension without using lib imghdr
我有一個非常適合接收 base64 圖像的視圖。 我的問題是在極少數情況下它無法識別發送的 jpg 圖像。 看起來像None 。 查看 inte.net 我發現問題出在 lib imghdr 上。 我嘗試使用 OS lib 來提取擴展,甚至使用 lib pillow,但我做不到。 有沒有人有任何提示 ...
[英]Determine image in memory
我想確定我擁有(下載)的緩沖區是否是圖像文件,而不將其保存到磁盤。 我查了一下,發現: imghdr 只能對文件執行此操作。 python-magic 可以給我文件類型,但我需要將它映射到圖像類型。 有更好的方法嗎? ...
[英]IOError when using imghdr module in Python
這是我的代碼,用於檢查存儲在許多文件夾中的文件的格式: check_image_format() : main() : 我的img_dir是其他三個子文件夾的根目錄,其中包含我要檢查的圖像。 當我啟動程序時,我收到此錯誤: 但是該文件存在並且位於子文件夾中。 此 ...
[英]imghdr / python - Can't detec type of some images (image extension)
我正在使用 Python 腳本從 imgur.com 下載大量圖像,並且由於我擁有格式為http://imgur.com/{id}所有鏈接,因此我必須通過將原始 url 替換為http://i.imgur.com/{id}.gif來強制下載它們http://i.imgur.com/{id}.gif ...
[英]why do python imghdr test functions take the file as an argument?
我正在查看imghdr模塊的源代碼,該模塊是python標准庫的一部分(我使用2.7)。 結構非常簡單- what函數在名稱為test_filetype類的函數列表中進行迭代,並且如果傳入的文件與任何測試匹配,它將返回該文件類型的字符串。 所有的test_filetype函數都test_ ...
[英]django content_type of a image while testing
我想獲取圖像的內容類型,而我正在做 它給我一個錯誤,說str對象沒有屬性content_type 如何獲取內容類型? 我正在測試中執行此操作,並且在我看來,我正在獲取圖像的content_type。 我可以將圖像傳遞到視圖,但不能給我內容類型 ...
[英]Open a picture via URL and detecting if it is png, jpg or gif in Python?
我想確定puush.me圖像(鏈接不是HTML,而是圖像)是png,jpg還是gif。 有沒有辦法做到這一點蟒蛇? Urllib似乎沒有打開圖像並檢測到它們。 ...
[英]python - How to use StringIO with imghdr to determine if valid image
如何使用帶有imghdr的StringIO來確定是否有效圖像 我加載了一張圖片 ...
[英]identifying the format of files
在linux中,我們有一個名為“file”的實用程序,它可以幫助我們確定文件的標識。 有沒有可以做同樣工作的python模塊? 我不喜歡使用subprocess.Popen(['file', 'blah.blah']) ,因為它與平台有關。 例如,Windows沒有“文件”(雖然可以下 ...
[英]How to check if a file is a valid image file?
我目前正在使用 PIL。 然而,雖然這足以涵蓋大多數情況,但未檢測到一些圖像文件,如 xcf、svg 和 psd。 Psd 文件會引發 OverflowError 異常。 有什么辦法我也可以包括它們嗎? ...