Пример #1
0
class VirtualMemoryArrayList(
        pretty_namedtuple('VirtualMemoryArrayList',
                          'version rectangle channels')):
    """
Пример #2
0
class ColorStop(pretty_namedtuple('ColorStop',
                                  'location midpoint mode color')):
    """
Пример #3
0
class Posterize(pretty_namedtuple('Posterize', 'value')):
    """
Пример #4
0
class SelectiveColor(
        pretty_namedtuple('SelectiveColor', 'version method items')):
    """
Пример #5
0
from __future__ import absolute_import, unicode_literals, print_function
import warnings
import io

from psd_tools.decoder import decoders
from psd_tools.decoder.actions import decode_descriptor, UnknownOSType
from psd_tools.decoder.color import decode_color
from psd_tools.exceptions import Error
from psd_tools.utils import read_fmt
from psd_tools.constants import EffectOSType, BlendMode
from psd_tools.debug import pretty_namedtuple

_effect_info_decoders, register = decoders.new_registry()


Effects = pretty_namedtuple('Effects', 'version effects_count effects_list')
_LayerEffect = pretty_namedtuple('LayerEffect', 'effect_type effect_info')
ObjectBasedEffects = pretty_namedtuple('ObjectBasedEffects', 'version descriptor_version descriptor')

CommonStateInfo = pretty_namedtuple('CommonStateInfo', 'version visible unused')
ShadowInfo = pretty_namedtuple('ShadowInfo', 'version enabled '
                                             'blend_mode color opacity '
                                             'angle use_global_angle '
                                             'distance intensity blur '
                                             'native_color')
OuterGlowInfo = pretty_namedtuple('OuterGlowInfo', 'version enabled '
                                                   'blend_mode opacity color '
                                                   'intensity blur '
                                                   'native_color')
InnerGlowInfo = pretty_namedtuple('InnerGlowInfo', 'version enabled '
                                                   'blend_mode opacity color '
Пример #6
0
from psd_tools.debug import pretty_namedtuple

_tagged_block_decoders, register = decoders.new_registry()

_tagged_block_decoders.update({
    TaggedBlock.BLEND_CLIPPING_ELEMENTS:            decoders.boolean("I"),
    TaggedBlock.BLEND_INTERIOR_ELEMENTS:            decoders.boolean("I"),
    TaggedBlock.KNOCKOUT_SETTING:                   decoders.boolean("I"),
    TaggedBlock.UNICODE_LAYER_NAME:                 decoders.unicode_string,
    TaggedBlock.LAYER_ID:                           decoders.single_value("I"), # XXX: there are more fields in docs, but they seem to be incorrect
    TaggedBlock.EFFECTS_LAYER:                      layer_effects.decode,
    TaggedBlock.OBJECT_BASED_EFFECTS_LAYER_INFO:    layer_effects.decode_object_based
})


SolidColorSettings = pretty_namedtuple('SolidColorSettings', 'version data')
MetadataItem = pretty_namedtuple('MetadataItem', 'sig key copy_on_sheet_duplication data')
ProtectedSetting = pretty_namedtuple('ProtectedSetting', 'transparency, composite, position')
TypeToolObjectSetting = pretty_namedtuple('TypeToolObjectSetting',
                        'version xx xy yx yy tx ty text_version descriptor1_version text_data '
                        'warp_version descriptor2_version warp_data left top right bottom')
VectorOriginationData = pretty_namedtuple('VectorOriginationData', 'version descriptor_version data')


class Divider(collections.namedtuple('Divider', 'block type key')):
    def __repr__(self):
        return "Divider(%s %r %s, %s)" % (
            self.block, self.type, SectionDivider.name_of(self.type), self.key)


def decode(tagged_blocks):
Пример #7
0
class BrightnessContrast(
        pretty_namedtuple('BrightnessContrast',
                          'brightness contrast mean lab')):
    """
Пример #8
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
import warnings

from psd_tools.utils import read_fmt
from psd_tools.constants import ColorSpaceID
from psd_tools.debug import pretty_namedtuple

_Color = pretty_namedtuple("Color", "color_space_id color_data")


class Color(_Color):
    def __repr__(self):
        return "Color(id=%s %s, %s)" % (self.color_space_id, ColorSpaceID.name_of(self.color_space_id), self.color_data)

    def _repr_pretty_(self, p, cycle):
        # IS NOT TESTED!!
        if cycle:
            p.text("Color(...)")
        else:
            with p.group(1, "Color(", ")"):
                p.breakable()
                p.text("id=%s %s," % (self.color_space_id, ColorSpaceID.name_of(self.color_space_id)))
                p.breakable()
                p.pretty(self.color_data)


def decode_color(fp):
    color_space_id = read_fmt("H", fp)[0]

    if not ColorSpaceID.is_known(color_space_id):
Пример #9
0
class PatternFillSetting(
        pretty_namedtuple('PatternFillSetting', 'version data')):
    """
Пример #10
0
class GradientFillSetting(
        pretty_namedtuple('GradientFillSetting', 'version data')):
    """
Пример #11
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals, division
import logging

import psd_tools.reader.header
import psd_tools.reader.color_mode_data
import psd_tools.reader.image_resources
import psd_tools.reader.layers
from psd_tools.debug import pretty_namedtuple

logger = logging.getLogger(__name__)

ParseResult = pretty_namedtuple(
    'ParseResult',
    'header, color_data, image_resource_blocks, layer_and_mask_data, image_data'
)

def parse(fp, encoding='utf8'):

    header = psd_tools.reader.header.read(fp)
    return ParseResult(
        header,
        psd_tools.reader.color_mode_data.read(fp),
        psd_tools.reader.image_resources.read(fp, encoding),
        psd_tools.reader.layers.read(fp, encoding, header.depth),
        psd_tools.reader.layers.read_image_data(fp, header)
    )
Пример #12
0
# -*- coding: utf-8 -*-
"""
A module for decoding "Actions" additional PSD data format.
"""
from __future__ import absolute_import, unicode_literals

from psd_tools.utils import read_unicode_string, read_fmt
from psd_tools.constants import OSType, ReferenceOSType, UnitFloatType
from psd_tools.debug import pretty_namedtuple
from psd_tools.utils import trimmed_repr

Descriptor = pretty_namedtuple('Descriptor', 'name classID items')
Reference = pretty_namedtuple('Descriptor', 'items')
Property = pretty_namedtuple('Property', 'name classID keyID')
UnitFloat = pretty_namedtuple('UnitFloat', 'unit value')
Double = pretty_namedtuple('Double', 'value')
Class = pretty_namedtuple('Class', 'name classID')
String = pretty_namedtuple('String', 'value')
EnumReference = pretty_namedtuple('String', 'name classID typeID enum')
Boolean = pretty_namedtuple('Boolean', 'value')
Offset = pretty_namedtuple('Offset', 'name classID value')
Alias = pretty_namedtuple('Alias', 'value')
List = pretty_namedtuple('List', 'items')
Integer = pretty_namedtuple('Integer', 'value')
Enum = pretty_namedtuple('Enum', 'type enum')
_EngineData = pretty_namedtuple('EngineData', 'value')


class EngineData(_EngineData):
    def __repr__(self):
        return "EngineData(value=%s)" % trimmed_repr(self.value)
Пример #13
0
import zlib

from psd_tools.utils import (read_fmt, read_pascal_string,
                             read_be_array, trimmed_repr, pad, synchronize)
from psd_tools.exceptions import Error
from psd_tools.constants import (Compression, Clipping, BlendMode,
                                 ChannelID, TaggedBlock)
from psd_tools import compression
from psd_tools.debug import pretty_namedtuple

logger = logging.getLogger(__name__)

_LayerRecord = pretty_namedtuple('LayerRecord', [
    'top', 'left', 'bottom', 'right',
    'num_channels', 'channels',
    'blend_mode', 'opacity', 'clipping', 'flags',
    'mask_data', 'blending_ranges', 'name',
    'tagged_blocks'
])

class LayerRecord(_LayerRecord):

    def width(self):
        return self.right - self.left

    def height(self):
        return self.bottom - self.top


Layers = pretty_namedtuple('Layers', 'length, layer_count, layer_records, channel_image_data')
LayerFlags = pretty_namedtuple('LayerFlags', 'transparency_protected visible')
Пример #14
0
class ExportSetting(pretty_namedtuple('ExportSetting', 'version data')):
    """
Пример #15
0
class LevelsSettings(pretty_namedtuple('LevelsSettings', 'version data')):
    """
Пример #16
0
class VectorStrokeContentSetting(
        pretty_namedtuple('VectorStrokeContentSetting', 'key version data')):
    """
Пример #17
0
class LevelRecord(
        pretty_namedtuple(
            'LevelRecord',
            'input_floor input_ceiling output_floor output_ceiling gamma')):
    """
Пример #18
0
# -*- coding: utf-8 -*-
"""
A module for decoding "Actions" additional PSD data format.
"""
from __future__ import absolute_import, unicode_literals

from psd_tools.utils import read_unicode_string, read_fmt
from psd_tools.constants import OSType, ReferenceOSType, UnitFloatType
from psd_tools.debug import pretty_namedtuple
from psd_tools.utils import trimmed_repr
import warnings

Descriptor = pretty_namedtuple('Descriptor', 'name classID items')
Reference = pretty_namedtuple('Reference', 'items')
Property = pretty_namedtuple('Property', 'name classID keyID')
UnitFloat = pretty_namedtuple('UnitFloat', 'unit value')
Double = pretty_namedtuple('Double', 'value')
Class = pretty_namedtuple('Class', 'name classID')
String = pretty_namedtuple('String', 'value')
EnumReference = pretty_namedtuple('EnumReference', 'name classID typeID enum')
Boolean = pretty_namedtuple('Boolean', 'value')
Offset = pretty_namedtuple('Offset', 'name classID value')
Alias = pretty_namedtuple('Alias', 'value')
List = pretty_namedtuple('List', 'items')
Integer = pretty_namedtuple('Integer', 'value')
Enum = pretty_namedtuple('Enum', 'type value')
Identifier = pretty_namedtuple('Identifier', 'value')
Index = pretty_namedtuple('Index', 'value')
Name = pretty_namedtuple('Name', 'value')
ObjectArray = pretty_namedtuple('ObjectArray', 'classObj items')
ObjectArrayItem = pretty_namedtuple('ObjectArrayItem', 'keyID value')
Пример #19
0
class CurvesSettings(
        pretty_namedtuple('CurvesSettings', 'version count data extra')):
    """
Пример #20
0
import zlib

from psd_tools.utils import (read_fmt, read_pascal_string,
                             read_be_array, trimmed_repr, pad, synchronize)
from psd_tools.exceptions import Error
from psd_tools.constants import (Compression, Clipping, BlendMode,
                                 ChannelID, TaggedBlock, ColorKind)
from psd_tools import compression
from psd_tools.debug import pretty_namedtuple

logger = logging.getLogger(__name__)

_LayerRecord = pretty_namedtuple('LayerRecord', [
    'top', 'left', 'bottom', 'right',
    'num_channels', 'channels',
    'blend_mode', 'opacity', 'clipping', 'flags',
    'mask_data', 'blending_ranges', 'name',
    'tagged_blocks'
])

class LayerRecord(_LayerRecord):

    def width(self):
        return self.right - self.left

    def height(self):
        return self.bottom - self.top


Layers = pretty_namedtuple('Layers', 'length, layer_count, layer_records, channel_image_data')
LayerFlags = pretty_namedtuple('LayerFlags', 'transparency_protected visible pixel_data_irrelevant')
Пример #21
0
class CurvesExtraMarker(
        pretty_namedtuple('CurvesExtraMarker', 'tag version count data')):
    """
Пример #22
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals, print_function
import warnings
import io
import struct

from psd_tools.utils import read_fmt, read_pascal_string, read_unicode_string
from psd_tools.debug import pretty_namedtuple
from psd_tools.decoder.actions import decode_descriptor

LinkedLayerCollection = pretty_namedtuple('LinkedLayerCollection', 'linked_list ')
_LinkedLayer = pretty_namedtuple('LinkedLayer',
                                 'version unique_id filename filetype file_open_descriptor '
                                 'creator decoded uuid')


class LinkedLayer(_LinkedLayer):

    def __repr__(self):
        return "LinkedLayer(filename='%s', size=%s)" % (self.filename, len(self.decoded))

    def _repr_pretty_(self, p, cycle):
        if cycle:
            p.text("LinkedLayer(...)")
        else:
            with p.group(1, "LinkedLayer(", ")"):
                p.breakable()
                p.text("filename='%s', " % self.filename)
                p.breakable()
                p.text("size=%s, " % len(self.decoded))
                p.breakable()
Пример #23
0
class CurveData(pretty_namedtuple('CurveData', 'channel points')):
    """
Пример #24
0
class Threshold(pretty_namedtuple('Threshold', 'value')):
    """
Пример #25
0
class Exposure(pretty_namedtuple('Exposure', 'version exposure offset gamma')):
    """
Пример #26
0
class Pattern(
        pretty_namedtuple(
            'Pattern',
            'version image_mode point name pattern_id color_table data')):
    """
Пример #27
0
class Vibrance(pretty_namedtuple('Vibrance', 'descriptor_version descriptor')):
    """
Пример #28
0
class VirtualMemoryArray(
        pretty_namedtuple(
            'VirtualMemoryArray',
            'is_written depth rectangle pixel_depth compression data')):
    """
Пример #29
0
class HueSaturation(
        pretty_namedtuple(
            'HueSaturation',
            'version enable_colorization colorization master items')):
    """
Пример #30
0
class TransparencyStop(
        pretty_namedtuple(
            'TransparencyStop',
            'location midpoint opacity expansion interpolation length mode')):
    """
Пример #31
0
class HueSaturationData(
        pretty_namedtuple('HueSaturationData', 'range settings')):
    """
Пример #32
0
class VectorStrokeSetting(
        pretty_namedtuple('VectorStrokeSetting', 'version data')):
    """
Пример #33
0
class ColorBalance(
        pretty_namedtuple('ColorBalance',
                          'shadows midtones highlights preserve_luminosity')):
    """
Пример #34
0
class MetadataItem(
        pretty_namedtuple(
            'MetadataItem',
            'key copy_on_sheet_duplication descriptor_version data')):
    """
Пример #35
0
class BlackWhite(
        pretty_namedtuple('BlackWhite', 'descriptor_version descriptor')):
    """
Пример #36
0
# -*- coding: utf-8 -*-
"""
A module for decoding "Actions" additional PSD data format.
"""
from __future__ import absolute_import, unicode_literals

from psd_tools.utils import read_unicode_string, read_fmt
from psd_tools.constants import OSType, ReferenceOSType, UnitFloatType
from psd_tools.debug import pretty_namedtuple
from psd_tools.utils import trimmed_repr
import warnings

Descriptor = pretty_namedtuple("Descriptor", "name classID items")
Reference = pretty_namedtuple("Reference", "items")
Property = pretty_namedtuple("Property", "name classID keyID")
UnitFloat = pretty_namedtuple("UnitFloat", "unit value")
Double = pretty_namedtuple("Double", "value")
Class = pretty_namedtuple("Class", "name classID")
String = pretty_namedtuple("String", "value")
EnumReference = pretty_namedtuple("EnumReference", "name classID typeID enum")
Boolean = pretty_namedtuple("Boolean", "value")
Offset = pretty_namedtuple("Offset", "name classID value")
Alias = pretty_namedtuple("Alias", "value")
List = pretty_namedtuple("List", "items")
Integer = pretty_namedtuple("Integer", "value")
Enum = pretty_namedtuple("Enum", "type value")
Identifier = pretty_namedtuple("Identifier", "value")
Index = pretty_namedtuple("Index", "value")
Name = pretty_namedtuple("Name", "value")
ObjectArray = pretty_namedtuple("ObjectArray", "classObj items")
ObjectArrayItem = pretty_namedtuple("ObjectArrayItem", "keyID value")
Пример #37
0
class PhotoFilter(
        pretty_namedtuple(
            'PhotoFilter',
            'version xyz color_space color_components density preserve_luminosity'
        )):
    """
Пример #38
0
from psd_tools.decoder import decoders
from psd_tools.reader.layers import Block
from psd_tools.debug import pretty_namedtuple

_tagged_block_decoders, register = decoders.new_registry()

_tagged_block_decoders.update({
    TaggedBlock.BLEND_CLIPPING_ELEMENTS:    decoders.boolean("I"),
    TaggedBlock.BLEND_INTERIOR_ELEMENTS:    decoders.boolean("I"),
    TaggedBlock.KNOCKOUT_SETTING:           decoders.boolean("I"),
    TaggedBlock.UNICODE_LAYER_NAME:         decoders.unicode_string,
    TaggedBlock.LAYER_ID:                   decoders.single_value("I") # XXX: there are more fields in docs, but they seem to be incorrect
})


SolidColorSettings = pretty_namedtuple('SolidColorSettings', 'version data')
MetadataItem = pretty_namedtuple('MetadataItem', 'sig key copy_on_sheet_duplication data')
ProtectedSetting = pretty_namedtuple('ProtectedSetting', 'transparency, composite, position')
TypeToolObjectSetting = pretty_namedtuple('TypeToolObjectSetting',
                        'version xx xy yx yy tx ty text_version descriptor_version1 text_data')
                        #'warp_version descriptor_version2 warp_data'
                        #'left top right bottom')


class Divider(collections.namedtuple('Divider', 'type key')):
    def __repr__(self):
        return "Divider(%r %s, %s)" % (self.type, SectionDivider.name_of(self.type), self.key)


def decode(tagged_blocks):
    """
Пример #39
0
class ChannelMixer(
        pretty_namedtuple('ChannelMixer',
                          'version monochrome mixer_settings')):
    """
Пример #40
0
# -*- coding: utf-8 -*-
"""
A module for decoding "Actions" additional PSD data format.
"""
from __future__ import absolute_import, unicode_literals
import warnings
from collections import namedtuple

from psd_tools.utils import read_unicode_string, read_fmt
from psd_tools.constants import OSType, ReferenceOSType, UnitFloatType
from psd_tools.debug import pretty_namedtuple
from psd_tools.utils import trimmed_repr

Descriptor = pretty_namedtuple("Descriptor", "name classID items")
Reference = pretty_namedtuple("Reference", "items")
Property = pretty_namedtuple("Property", "name classID keyID")
UnitFloat = namedtuple("UnitFloat", "unit value")
Double = namedtuple("Double", "value")
Class = pretty_namedtuple("Class", "name classID")
String = pretty_namedtuple("String", "value")
EnumReference = pretty_namedtuple("EnumReference", "name classID typeID enum")
Boolean = namedtuple("Boolean", "value")
Offset = pretty_namedtuple("Offset", "name classID value")
Alias = pretty_namedtuple("Alias", "value")
List = pretty_namedtuple("List", "items")
Integer = namedtuple("Integer", "value")
Enum = pretty_namedtuple("Enum", "type value")
Identifier = namedtuple("Identifier", "value")
Index = namedtuple("Index", "value")
Name = pretty_namedtuple("Name", "value")
ObjectArray = pretty_namedtuple("ObjectArray", "classObj items")
Пример #41
0
class ColorLookup(
        pretty_namedtuple('ColorLookup',
                          'version descriptor_version descriptor')):
    """
Пример #42
0
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals, division
import logging

from psd_tools.utils import read_fmt, trimmed_repr, read_pascal_string, pad
from psd_tools.exceptions import Error
from psd_tools.constants import ImageResourceID
from psd_tools.debug import pretty_namedtuple

logger = logging.getLogger(__name__)

_ImageResource = pretty_namedtuple("ImageResource", "resource_id, name, data")

class ImageResource(_ImageResource):

    def __repr__(self):
        return "ImageResource(%r %s, %r, %s)" % (
            self.resource_id, ImageResourceID.name_of(self.resource_id),
            self.name, trimmed_repr(self.data)
        )

    def _repr_pretty_(self, p, cycle):
        if cycle:
            p.text(repr(self))
        else:
            with p.group(0, 'ImageResource(', ')'):
                p.text("%r %s, %r, " % (
                    self.resource_id, ImageResourceID.name_of(self.resource_id),
                    self.name
                ))
                if isinstance(self.data, bytes):
Пример #43
0
class Invert(pretty_namedtuple('Invert', '')):
    """
Пример #44
0
        TaggedBlock.BLEND_CLIPPING_ELEMENTS: decoders.boolean,
        TaggedBlock.BLEND_INTERIOR_ELEMENTS: decoders.boolean,
        TaggedBlock.KNOCKOUT_SETTING: decoders.boolean,
        TaggedBlock.UNICODE_LAYER_NAME: decoders.unicode_string,
        TaggedBlock.LAYER_ID: decoders.single_value("I"),
        TaggedBlock.FILL_OPACITY: decoders.single_value("B"),
        TaggedBlock.EFFECTS_LAYER: layer_effects.decode,
        TaggedBlock.OBJECT_BASED_EFFECTS_LAYER_INFO: layer_effects.decode_object_based,
        TaggedBlock.LINKED_LAYER1: linked_layer.decode,
        TaggedBlock.LINKED_LAYER2: linked_layer.decode,
        TaggedBlock.LINKED_LAYER3: linked_layer.decode,
    }
)


SolidColorSettings = pretty_namedtuple("SolidColorSettings", "version data")
MetadataItem = pretty_namedtuple("MetadataItem", "key copy_on_sheet_duplication descriptor_version data")
ProtectedSetting = pretty_namedtuple("ProtectedSetting", "transparency, composite, position")
TypeToolObjectSetting = pretty_namedtuple(
    "TypeToolObjectSetting",
    "version xx xy yx yy tx ty text_version descriptor1_version text_data "
    "warp_version descriptor2_version warp_data left top right bottom",
)
VectorOriginationData = pretty_namedtuple("VectorOriginationData", "version descriptor_version data")
FilterMask = pretty_namedtuple("FilterMask", "color opacity")


class Divider(pretty_namedtuple("Divider", "type blend_mode sub_type")):
    def __repr__(self):
        blend_mode = self.blend_mode
        if blend_mode is not None:
Пример #45
0
    ImageResourceID.ICC_UNTAGGED_PROFILE:       decoders.boolean,
    ImageResourceID.EFFECTS_VISIBLE:            decoders.boolean,
    ImageResourceID.IDS_SEED_NUMBER:            decoders.single_value("I"),
    ImageResourceID.INDEXED_COLOR_TABLE_COUNT:  decoders.single_value("H"),
    ImageResourceID.TRANSPARENCY_INDEX:         decoders.single_value("H"),
    ImageResourceID.GLOBAL_ALTITUDE:            decoders.single_value("I"),
    ImageResourceID.GLOBAL_ANGLE:               decoders.single_value("I"),
    ImageResourceID.COPYRIGHT_FLAG:             decoders.boolean,

    ImageResourceID.ALPHA_NAMES_PASCAL:         decoders.pascal_string,
    ImageResourceID.CAPTION_PASCAL:             decoders.pascal_string,
    ImageResourceID.WORKFLOW_URL:               decoders.unicode_string
})

_PrintScale = namedtuple('PrintScale', 'style, x, y, scale')
PrintFlags = pretty_namedtuple('PrintFlags', 'labels, crop_marks, color_bars, registration_marks, negative, flip, interpolate, caption, print_flags')
PrintFlagsInfo = pretty_namedtuple('PrintFlagsInfo', 'version, center_crop_marks, bleed_width_value, bleed_width_scale')
VersionInfo = pretty_namedtuple('VersionInfo', 'version, has_real_merged_data, writer_name, reader_name, file_version')
PixelAspectRatio = namedtuple('PixelAspectRatio', 'version aspect')
_ResolutionInfo = pretty_namedtuple('ResolutionInfo', 'h_res, h_res_unit, width_unit, v_res, v_res_unit, height_unit')
PathSelectionState = pretty_namedtuple('PathSelectionState', 'descriptor_version descriptor')
LayerComps = pretty_namedtuple('LayerComps', 'descriptor_version descriptor')
_DisplayInfo = pretty_namedtuple('DisplayInfo', 'color opacity color_kind')


class ResolutionInfo(_ResolutionInfo):

    def __repr__(self):
        return "ResolutionInfo(h_res=%s, h_res_unit=%s, v_res=%s, v_res_unit=%s, width_unit=%s, height_unit=%s)" % (
            self.h_res,
            DisplayResolutionUnit.name_of(self.h_res_unit),