Beispiel #1
0
def test_render_quality(filename):
    psd = PSDImage.load(full_name(filename))
    preview = psd.as_PIL()
    rendered = psd.as_PIL(render=True)
    assert isinstance(preview, Image)
    assert isinstance(rendered, Image)
    preview_hash = imagehash.average_hash(preview)
    rendered_hash = imagehash.average_hash(rendered)
    error_count = np.sum(np.bitwise_xor(preview_hash.hash, rendered_hash.hash))
    error_rate = error_count / float(preview_hash.hash.size)
    assert error_rate <= 0.1
Beispiel #2
0
def test_render_clip_layers(filename):
    psd = PSDImage.load(full_name(filename))
    image1 = psd.as_PIL()
    image2 = psd.as_PIL(render=True)
    assert isinstance(image1, Image)
    assert isinstance(image2, Image)
def test_thumbnail(filename):
    psd = PSDImage.load(full_name(filename))
    assert psd.thumbnail()
def test_resource_blocks():
    psd = PSDImage.load(full_name("fill_adjustments.psd"))
    blocks = psd.image_resource_blocks
    assert "version_info" in blocks
Beispiel #5
0
def test_generator():
    psd = PSDImage.load(full_name('hidden-groups.psd'))
    assert len([True for layer in psd.layers]) == 3
    assert len([True for layer in psd.descendants()]) == 5
Beispiel #6
0
def test_generator_with_clip_layers():
    psd = PSDImage.load(full_name('clipping-mask.psd'))
    assert not psd.layers[0].has_clip_layers()
    assert len([True for layer in psd.layers]) == 2
    assert len([True for layer in psd.descendants()]) == 7
    assert len([True for layer in psd.descendants(include_clip=False)]) == 6