新月の開発

ff5f310f :Anonymous 2015-03-02 22:18
画像の誤認識、メタデータの付いてないJPEGで起こるみたい(よく見るとimghdrのドキュメントにも"JPEG in JFIF or Exif"とか書かれてる)

↓取り敢えず自分はこんな感じで回避してるので、必要な人はどうぞ
diff --git a/shingetsu/attachutil.py b/shingetsu/attachutil.py
index c14edfb..855af96 100644
--- a/shingetsu/attachutil.py
+++ b/shingetsu/attachutil.py
@@ -37,6 +37,12 @@ __all__ = ['is_valid_image']
# For Unittest
_imghdr = imghdr

+def test_jpeg_aggressive(h, f):
+ """recognize JPEG aggressively"""
+ if h.startswith(b'\xFF\xD8\xFF'):
+ return 'jpeg'
+
+imghdr.tests.append(test_jpeg_aggressive)

def is_valid_image(mimetype, path):
"""Type of path is same as mimetype or not.
Powered by shinGETsu.