本文整理汇总了Python中PIL.GifImagePlugin.getheader方法的典型用法代码示例。如果您正苦于以下问题:Python GifImagePlugin.getheader方法的具体用法?Python GifImagePlugin.getheader怎么用?Python GifImagePlugin.getheader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PIL.GifImagePlugin
的用法示例。
在下文中一共展示了GifImagePlugin.getheader方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_getdata
# 需要导入模块: from PIL import GifImagePlugin [as 别名]
# 或者: from PIL.GifImagePlugin import getheader [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
示例2: get_cKDTree
# 需要导入模块: from PIL import GifImagePlugin [as 别名]
# 或者: from PIL.GifImagePlugin import getheader [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).
示例3: getheaderAnim
# 需要导入模块: from PIL import GifImagePlugin [as 别名]
# 或者: from PIL.GifImagePlugin import getheader [as 别名]
def getheaderAnim(self, im):
""" getheaderAnim(im)
Get animation header. To replace PILs getheader()[0]
"""
bb = "GIF89a"
bb += intToBin(im.size[0])
bb += intToBin(im.size[1])
bb += "\x87\x00\x00"
return bb
示例4: getheaderAnim
# 需要导入模块: from PIL import GifImagePlugin [as 别名]
# 或者: from PIL.GifImagePlugin import getheader [as 别名]
def getheaderAnim(self, im):
""" getheaderAnim(im)
Get animation header. To replace PILs getheader()[0]
"""
bb = b'GIF89a'
bb += intToBin(im.size[0])
bb += intToBin(im.size[1])
bb += b'\x87\x00\x00'
return bb
示例5: getheaderAnim
# 需要导入模块: from PIL import GifImagePlugin [as 别名]
# 或者: from PIL.GifImagePlugin import getheader [as 别名]
def getheaderAnim(self, im):
""" getheaderAnim(im)
Get animation header. To replace PILs getheader()[0]
"""
bb = "GIF89a"
bb += intToBin(im.size[0])
bb += intToBin(im.size[1])
bb += "\x87\x00\x00"
return bb
示例6: getheaderAnim
# 需要导入模块: from PIL import GifImagePlugin [as 别名]
# 或者: from PIL.GifImagePlugin import getheader [as 别名]
def getheaderAnim(im):
""" Animation header. To replace the getheader()[0] """
bb = "GIF89a"
bb += intToBin(im.size[0])
bb += intToBin(im.size[1])
bb += "\x87\x00\x00"
return bb
示例7: get_cKDTree
# 需要导入模块: from PIL import GifImagePlugin [as 别名]
# 或者: from PIL.GifImagePlugin import getheader [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).
示例8: getheaderAnim
# 需要导入模块: from PIL import GifImagePlugin [as 别名]
# 或者: from PIL.GifImagePlugin import getheader [as 别名]
def getheaderAnim(self, im):
""" getheaderAnim(im)
Get animation header. To replace PILs getheader()[0]
"""
bb = b"GIF89a"
bb += intToBin(im.size[0])
bb += intToBin(im.size[1])
bb += b"\x87\x00\x00"
return bb
示例9: get_cKDTree
# 需要导入模块: from PIL import GifImagePlugin [as 别名]
# 或者: from PIL.GifImagePlugin import getheader [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).
示例10: makedelta
# 需要导入模块: from PIL import GifImagePlugin [as 别名]
# 或者: from PIL.GifImagePlugin import getheader [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