本文整理汇总了Python中sigal.image.generate_image函数的典型用法代码示例。如果您正苦于以下问题:Python generate_image函数的具体用法?Python generate_image怎么用?Python generate_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_image函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_generate_image
def test_generate_image(tmpdir):
"Test the generate_image function."
dstfile = str(tmpdir.join(TEST_IMAGE))
for size in [(600, 600), (300, 200)]:
generate_image(SRCFILE, dstfile, size, None, method='ResizeToFill')
im = Image.open(dstfile)
assert im.size == size
示例2: test_generate_image_processor
def test_generate_image_processor(tmpdir):
"Test generate_image with a wrong processor name."
init_logging()
dstfile = str(tmpdir.join(TEST_IMAGE))
with pytest.raises(SystemExit):
generate_image(SRCFILE, dstfile, (200, 200), None,
method='WrongMethod')
示例3: test_generate_image_processor
def test_generate_image_processor(tmpdir):
"Test generate_image with a wrong processor name."
init_logging()
dstfile = str(tmpdir.join(TEST_IMAGE))
with pytest.raises(SystemExit):
settings = create_settings(img_size=(200, 200), img_processor="WrongMethod")
generate_image(SRCFILE, dstfile, settings)
示例4: test_generate_image_passthrough_symlink
def test_generate_image_passthrough_symlink(tmpdir):
"Test the generate_image function with use_orig=True and orig_link=True."
dstfile = str(tmpdir.join(TEST_IMAGE))
settings = create_settings(use_orig=True, orig_link=True)
generate_image(SRCFILE, dstfile, settings)
# Check the file was symlinked
assert os.path.islink(dstfile)
assert os.path.samefile(SRCFILE, dstfile)
示例5: test_generate_image
def test_generate_image(tmpdir):
"Test the generate_image function."
dstfile = str(tmpdir.join(TEST_IMAGE))
for size in [(600, 600), (300, 200)]:
settings = create_settings(img_size=size, img_processor='ResizeToFill')
generate_image(SRCFILE, dstfile, settings)
im = Image.open(dstfile)
assert im.size == size
示例6: test_generate_image_passthrough
def test_generate_image_passthrough(tmpdir, image, path):
"Test the generate_image function with use_orig=True."
dstfile = str(tmpdir.join(image))
settings = create_settings(use_orig=True)
generate_image(path, dstfile, settings)
# Check the file was copied, not (sym)linked
st_src = os.stat(path)
st_dst = os.stat(dstfile)
assert st_src.st_size == st_dst.st_size
assert not os.path.samestat(st_src, st_dst)
示例7: test_generate_image
def test_generate_image(tmpdir):
"Test the generate_image function."
dstfile = str(tmpdir.join(TEST_IMAGE))
for i, size in enumerate([(600, 600), (300, 200)]):
settings = create_settings(img_size=size, img_processor='ResizeToFill',
copy_exif_data=True)
options = None if i == 0 else {'quality': 85}
generate_image(SRCFILE, dstfile, settings, options=options)
im = Image.open(dstfile)
assert im.size == size