CMSimple Drupal Yii 內容管理系統三方案 - 提升台灣中小企業競爭力

目前位置:   首頁 > Program Talk > gif2jpg.py

gif2jpg.py

將 gif 格式圖檔轉為 jpg 檔案.

from PIL import Image
import sys
def gifTojpg(infile):
    try:
        im = Image.open(infile)
        filename, ext = infile.split(".")
    except IOError:
        print("Cant load", infile)
        sys.exit(1)
    i = 0
    mypalette = im.getpalette()
    try:
        while 1:
            im.putpalette(mypalette)
            new_im = Image.new("RGBA", im.size)
            new_im.paste(im)
            #new_im.save('test'+str(i)+'.jpg')
            new_im.save(filename+'.jpg')
            i += 1
            im.seek(im.tell() + 1)
    except EOFError:
        pass # end of sequence
processImage('test.gif')

Powered by CMSimple_XH| Template: ge-webdesign.de| 登入