當前位置: 首頁>>代碼示例>>Python>>正文


Python GifImagePlugin.getdata方法代碼示例

本文整理匯總了Python中PIL.GifImagePlugin.getdata方法的典型用法代碼示例。如果您正苦於以下問題:Python GifImagePlugin.getdata方法的具體用法?Python GifImagePlugin.getdata怎麽用?Python GifImagePlugin.getdata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PIL.GifImagePlugin的用法示例。


在下文中一共展示了GifImagePlugin.getdata方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_getdata

# 需要導入模塊: from PIL import GifImagePlugin [as 別名]
# 或者: from PIL.GifImagePlugin import getdata [as 別名]
def test_getdata(self):
        # test getheader/getdata against legacy values
        # Create a 'P' image with holes in the palette
        im = Image._wedge().resize((16, 16))
        im.putpalette(ImagePalette.ImagePalette('RGB'))
        im.info = {'background': 0}

        passed_palette = bytes(bytearray([255-i//3 for i in range(768)]))

        GifImagePlugin._FORCE_OPTIMIZE = True
        try:
            h = GifImagePlugin.getheader(im, passed_palette)
            d = GifImagePlugin.getdata(im)

            import pickle
            # Enable to get target values on pre-refactor version
            # with open('Tests/images/gif_header_data.pkl', 'wb') as f:
            #    pickle.dump((h, d), f, 1)
            with open('Tests/images/gif_header_data.pkl', 'rb') as f:
                (h_target, d_target) = pickle.load(f)

            self.assertEqual(h, h_target)
            self.assertEqual(d, d_target)
        finally:
            GifImagePlugin._FORCE_OPTIMIZE = False 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:27,代碼來源:test_file_gif.py

示例2: get_cKDTree

# 需要導入模塊: from PIL import GifImagePlugin [as 別名]
# 或者: from PIL.GifImagePlugin import getdata [as 別名]
def get_cKDTree():
    try:
        from scipy.spatial import cKDTree
    except ImportError:
        cKDTree = None
    return cKDTree


# getheader gives a 87a header and a color palette (two elements in a list).
# getdata()[0] gives the Image Descriptor up to (including) "LZW min code size".
# getdatas()[1:] is the image data itself in chuncks of 256 bytes (well
# technically the first byte says how many bytes follow, after which that
# amount (max 255) follows). 
開發者ID:beefoo,項目名稱:music-lab-scripts,代碼行數:15,代碼來源:images2gif.py

示例3: get_cKDTree

# 需要導入模塊: from PIL import GifImagePlugin [as 別名]
# 或者: from PIL.GifImagePlugin import getdata [as 別名]
def get_cKDTree():
	try:
		from scipy.spatial import cKDTree
	except ImportError:
		cKDTree = None
	return cKDTree
	
	
# getheader gives a 87a header and a color palette (two elements in a list).
# getdata()[0] gives the Image Descriptor up to (including) "LZW min code size".
# getdatas()[1:] is the image data itself in chuncks of 256 bytes (well
# technically the first byte says how many bytes follow, after which that
# amount (max 255) follows). 
開發者ID:Tyulis,項目名稱:3DSkit,代碼行數:15,代碼來源:image2gif.py

示例4: get_cKDTree

# 需要導入模塊: from PIL import GifImagePlugin [as 別名]
# 或者: from PIL.GifImagePlugin import getdata [as 別名]
def get_cKDTree():
    try:
        from scipy.spatial import cKDTree
    except ImportError:
        cKDTree = None
    return cKDTree


# getheader gives a 87a header and a color palette (two elements in a list).
# getdata()[0] gives the Image Descriptor up to (including) "LZW min code size"
# getdatas()[1:] is the image data itself in chuncks of 256 bytes (well
# technically the first byte says how many bytes follow, after which that
# amount (max 255) follows). 
開發者ID:kesara,項目名稱:deepdreamer,代碼行數:15,代碼來源:images2gif.py

示例5: makedelta

# 需要導入模塊: from PIL import GifImagePlugin [as 別名]
# 或者: from PIL.GifImagePlugin import getdata [as 別名]
def makedelta(fp, sequence):
    """Convert list of image frames to a GIF animation file"""

    frames = 0

    previous = None

    for im in sequence:

        # To specify duration, add the time in milliseconds to getdata(),
        # e.g. getdata(im, duration=1000)

        if not previous:

            # global header
            loops = 2 ** 16 - 1
            for s in getheader(im, info={"loop": loops})[0] + getdata(im, duration=10, loop=2 ** 16 - 1):
                fp.write(s)

        else:

            # delta frame
            delta = ImageChops.subtract_modulo(im, previous)

            bbox = delta.getbbox()

            if bbox:

                # compress difference
                for s in getdata(im.crop(bbox), offset=bbox[:2], duration=10):
                    fp.write(s)

            else:
                # FIXME: what should we do in this case?
                pass

        previous = im.copy()

        frames += 1

    fp.write(b";")

    return frames 
開發者ID:Bartzi,項目名稱:stn-ocr,代碼行數:45,代碼來源:create_gif.py


注:本文中的PIL.GifImagePlugin.getdata方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。