Example #1
0
def test_compose_quality(filename):
    psd = PSDImage.open(full_name(filename))
    preview = psd.topil()
    rendered = psd.compose(force=True)
    assert _calculate_hash_error(preview, rendered) <= 0.1
Example #2
0
def group():
    return PSDImage.open(full_name('layers/group.psd'))[0]
Example #3
0
from __future__ import absolute_import, unicode_literals
import pytest
import logging
import os

from psd_tools2.api.psd_image import PSDImage

from ..utils import full_name

logger = logging.getLogger(__name__)

LAYER_EFFECTS = PSDImage.open(full_name('layer_effects.psd'))


@pytest.fixture
def fixture():
    yield LAYER_EFFECTS


def test_effects(fixture):
    assert isinstance(fixture[0].effects.scale, float)
    assert fixture[0].effects.enabled is True
    for effect in fixture[0].effects:
        assert effect.enabled is True


def test_bevel(fixture):
    effect = fixture[1].effects[0]
    assert not hasattr(effect, 'blend_mode')
    assert effect.altitude == 30.0
    assert effect.angle == 90.0
Example #4
0
def smartobject_layer():
    return PSDImage.open(full_name('layers/smartobject-layer.psd'))[0]
Example #5
0
def type_layer():
    return PSDImage.open(full_name('layers/type-layer.psd'))[0]
Example #6
0
def test_solid_color_fill():
    layer = PSDImage.open(full_name('layers/solid-color-fill.psd'))[0]
    assert layer.data
Example #7
0
def fill_layer():
    return PSDImage.open(full_name('layers/solid-color-fill.psd'))[0]
Example #8
0
def pixel_layer():
    return PSDImage.open(full_name('layers/pixel-layer.psd'))[0]
Example #9
0
def test_clip_adjustment():
    psd = PSDImage.open(full_name('clip-adjustment.psd'))
    assert len(psd) == 1
    layer = psd[0]
    assert layer.kind == 'type'
    assert len(layer.clip_layers) == 1
Example #10
0
def layer_mask_data():
    return PSDImage.open(full_name('layer_mask_data.psd'))
Example #11
0
from __future__ import absolute_import, unicode_literals
import pytest
import logging
import os

from psd_tools2.api.psd_image import PSDImage

from ..utils import full_name

logger = logging.getLogger(__name__)

PLACED_LAYER = PSDImage.open(full_name('placedLayer.psd'))


@pytest.fixture
def embedded_object():
    yield PLACED_LAYER[3].smart_object


@pytest.fixture
def external_object():
    yield PLACED_LAYER[1].smart_object


@pytest.fixture
def linked_layer_png():
    with open(full_name('linked-layer.png'), 'rb') as f:
        yield f.read()


def test_smart_object_data(embedded_object, linked_layer_png, tmpdir):
Example #12
0
from __future__ import absolute_import, unicode_literals
import pytest
import logging

from psd_tools2.api.psd_image import PSDImage
from psd_tools2.api.shape import (Rectangle, RoundedRectangle, Ellipse, Line,
                                  Invalidated)

from ..utils import full_name

logger = logging.getLogger(__name__)

VECTOR_MASK2 = PSDImage.open(full_name('vector-mask2.psd'))


@pytest.fixture
def psd():
    return VECTOR_MASK2


def test_layer_properties(psd):
    for index in range(len(psd)):
        layer = psd[index]
        assert layer.has_vector_mask() is True
        assert layer.vector_mask
        expected = index != 0
        assert layer.has_origination() is expected
        if expected:
            assert layer.origination
        else:
            assert not layer.origination
Example #13
0
def test_pattern_fill():
    layer = PSDImage.open(full_name('layers/pattern-fill.psd'))[0]
    assert layer.data
Example #14
0
def test_gradient_fill():
    layer = PSDImage.open(full_name('layers/gradient-fill.psd'))[0]
    assert layer.angle
    assert layer.gradient_kind
    assert layer.data
Example #15
0
def test_compose_minimal(filename):
    source = PSDImage.open(full_name('layers-minimal/' + filename)).compose()
    reference = PSDImage.open(full_name('layers/' + filename)).compose(True)
    assert _calculate_hash_error(source, reference) <= 0.172
Example #16
0
def adjustment_layer():
    return PSDImage.open(full_name('layers/brightness-contrast.psd'))[0]
Example #17
0
def test_compose_colormodes(colormode, depth):
    filename = 'colormodes/4x4_%gbit_%s.psd' % (depth, colormode)
    psd = PSDImage.open(full_name(filename))
    assert isinstance(psd.compose(), Image)
Example #18
0
from __future__ import absolute_import, unicode_literals
import pytest
import logging
import os

from psd_tools2.api.psd_image import PSDImage
from psd_tools2.api import adjustments

from ..utils import full_name

logger = logging.getLogger(__name__)

FILL_ADJUSTMENTS = PSDImage.open(full_name('fill_adjustments.psd'))


@pytest.fixture(scope="module")
def psd():
    return FILL_ADJUSTMENTS


def test_solid_color_fill():
    layer = PSDImage.open(full_name('layers/solid-color-fill.psd'))[0]
    assert layer.data


def test_gradient_fill():
    layer = PSDImage.open(full_name('layers/gradient-fill.psd'))[0]
    assert layer.angle
    assert layer.gradient_kind
    assert layer.data