当前位置: 首页>>代码示例>>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;未经允许,请勿转载。