lobatt / gaephotos

Automatically exported from code.google.com/p/gaephotos
0 stars 0 forks source link

請問可否添加新的圖片格式? #42

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
想增加WebP格式的圖片
但是提示不支援
已修改utils.py的代碼
添加為這樣:
class ImageMime:
    GIF = "image/gif"
    JPEG = "image/jpeg"
    TIFF = "image/tiff"
    PNG = "image/png"
    BMP = "image/bmp"
    ICO = "image/x-icon"
    WEBP = "image/webp"
    UNKNOWN = "application/octet-stream"

def get_img_type(binary):
    size = len(binary)
    if size >= 6 and binary.startswith("GIF"):
        return ImageMime.GIF
    elif size >= 8 and binary.startswith("\x89PNG\x0D\x0A\x1A\x0A"):
        return ImageMime.PNG
    elif size >= 2 and binary.startswith("\xff\xD8"):
        return ImageMime.JPEG
    elif (size >= 8 and (binary.startswith("II\x2a\x00") or
                         binary.startswith("MM\x00\x2a"))):
        return ImageMime.TIFF
    elif size >= 2 and binary.startswith("BM"):
        return ImageMime.BMP
    elif size >= 4 and binary.startswith("\x00\x00\x01\x00"):
        return ImageMime.ICO
    elif size >= 4 and binary.startswith("RIFF"):
        return ImageMime.WEBP
    else:
        return ImageMime.UNKNOWN

好像還是不行,請問怎麼解決呢?

Original issue reported on code.google.com by jhan...@gmail.com on 3 Sep 2012 at 9:02

Attachments:

GoogleCodeExporter commented 8 years ago
可能是浏览器还不支持WebP格式的图片吧

Original comment by deepgu...@gmail.com on 26 Dec 2012 at 3:28

GoogleCodeExporter commented 8 years ago
1.這不是瀏覽器的問題,服務端圖片格式報錯
2.Chrome已經支援WebP格式

Original comment by jhan...@gmail.com on 26 Dec 2012 at 3:30

GoogleCodeExporter commented 8 years ago
可以发一下出错的log吗?

Original comment by deepgu...@gmail.com on 26 Dec 2012 at 5:35