Exemplo n.º 1
0
from psd_tools.constants import TaggedBlock, SectionDivider
from psd_tools.decoder.actions import decode_descriptor, UnknownOSType
from psd_tools.utils import read_fmt, read_unicode_string, unpack
from psd_tools.decoder import decoders, layer_effects
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
    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')):
Exemplo n.º 2
0
from psd_tools.decoder.color import decode_color
from psd_tools.utils import read_fmt, unpack
from psd_tools.decoder import decoders, layer_effects, linked_layer
from psd_tools.reader.layers import Block
from psd_tools.debug import pretty_namedtuple
from psd_tools.exceptions import Error

_tagged_block_decoders, register = decoders.new_registry()

_tagged_block_decoders.update(
    {
        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",
Exemplo n.º 3
0
import warnings
import collections

from psd_tools.utils import (read_pascal_string, unpack, read_fmt,
                             read_unicode_string, be_array_from_bytes,
                             decode_fixed_point_32bit)
from psd_tools.constants import ImageResourceID, PrintScaleStyle, DisplayResolutionUnit, DimensionUnit
from psd_tools.decoder import decoders
from psd_tools.decoder.actions import decode_descriptor, UnknownOSType
from psd_tools.decoder.color import decode_color

_image_resource_decoders, register = decoders.new_registry()

_image_resource_decoders.update({
    ImageResourceID.LAYER_STATE_INFO:
    decoders.single_value("H"),
    ImageResourceID.WATERMARK:
    decoders.single_value("B"),
    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_OBSOLETE:
Exemplo n.º 4
0
from __future__ import absolute_import, unicode_literals, division
import io
import warnings
import collections

from psd_tools.utils import (read_pascal_string, unpack, read_fmt,
                             read_unicode_string, be_array_from_bytes,
                             decode_fixed_point_32bit)
from psd_tools.constants import ImageResourceID, PrintScaleStyle, DisplayResolutionUnit, DimensionUnit
from psd_tools.decoder import decoders
from psd_tools.decoder.actions import decode_descriptor, UnknownOSType

_image_resource_decoders, register = decoders.new_registry()

_image_resource_decoders.update({
    ImageResourceID.LAYER_STATE_INFO:           decoders.single_value("H"),
    ImageResourceID.WATERMARK:                  decoders.single_value("B"),
    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_OBSOLETE:      decoders.single_value("I"),
    ImageResourceID.COPYRIGHT_FLAG:             decoders.boolean("H"),

    ImageResourceID.ALPHA_NAMES_UNICODE:        decoders.unicode_string,
    ImageResourceID.WORKFLOW_URL:               decoders.unicode_string,
})

PrintScale = collections.namedtuple('PrintScale', 'style, x, y, scale')
Exemplo n.º 5
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,
    TaggedBlock.LFXS:
    layer_effects.decode_object_based,
    TaggedBlock.PATTERNS1:
    layer_effects.decode_pattern,
    TaggedBlock.PATTERNS2:
    layer_effects.decode_pattern,
    TaggedBlock.PATTERNS3:
    layer_effects.decode_pattern,
    TaggedBlock.VECTOR_MASK_SETTING1:
    layer_effects.decode_vector_mask,
Exemplo n.º 6
0
import warnings
from collections import namedtuple
from psd_tools.utils import (read_pascal_string, unpack, read_fmt,
                             read_unicode_string, be_array_from_bytes,
                             decode_fixed_point_32bit)
from psd_tools.constants import (ImageResourceID, PrintScaleStyle,
                                 DisplayResolutionUnit, DimensionUnit)
from psd_tools.decoder import decoders
from psd_tools.decoder.actions import decode_descriptor, UnknownOSType, RawData
from psd_tools.decoder.color import decode_color
from psd_tools.decoder.path import decode_path_resource

_image_resource_decoders, register = decoders.new_registry()

_image_resource_decoders.update({
    ImageResourceID.LAYER_STATE_INFO:           decoders.single_value("H"),
    ImageResourceID.WATERMARK:                  decoders.single_value("B"),
    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("H"),

    ImageResourceID.ALPHA_NAMES_UNICODE:        decoders.unicode_string,
    ImageResourceID.WORKFLOW_URL:               decoders.unicode_string,
    ImageResourceID.AUTO_SAVE_FILE_PATH:        decoders.unicode_string,
    ImageResourceID.AUTO_SAVE_FORMAT:           decoders.unicode_string,
})
Exemplo n.º 7
0
from psd_tools.decoder import decoders, layer_effects
from psd_tools.decoder.color import decode_color
from psd_tools.decoder.path import decode_path_resource
from psd_tools.reader.layers import Block
from psd_tools.debug import pretty_namedtuple
from psd_tools.decoder import engine_data

_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.BLEND_FILL_OPACITY:
    decoders.single_value("4B"),
    TaggedBlock.KNOCKOUT_SETTING:
    decoders.boolean("I"),
    TaggedBlock.UNICODE_LAYER_NAME:
    decoders.unicode_string,
    # XXX: there are more fields in docs, but they seem to be incorrect
    TaggedBlock.LAYER_ID:
    decoders.single_value("I"),
    TaggedBlock.EFFECTS_LAYER:
    layer_effects.decode,
    TaggedBlock.OBJECT_BASED_EFFECTS_LAYER_INFO:
    layer_effects.decode_object_based,
    TaggedBlock.OBJECT_BASED_EFFECTS_LAYER_INFO_V0:
    layer_effects.decode_object_based,
    TaggedBlock.OBJECT_BASED_EFFECTS_LAYER_INFO_V1:
    layer_effects.decode_object_based,
Exemplo n.º 8
0
from psd_tools.utils import (
    read_fmt, unpack, read_unicode_string, read_pascal_string
)
from psd_tools.decoder import decoders, layer_effects
from psd_tools.decoder.color import decode_color
from psd_tools.decoder.path import decode_path_resource
from psd_tools.reader.layers import Block
from psd_tools.debug import pretty_namedtuple
from psd_tools.decoder import engine_data

_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.BLEND_FILL_OPACITY: decoders.single_value("4B"),
    TaggedBlock.KNOCKOUT_SETTING: decoders.boolean("I"),
    TaggedBlock.UNICODE_LAYER_NAME: decoders.unicode_string,
    # XXX: there are more fields in docs, but they seem to be incorrect
    TaggedBlock.LAYER_ID: decoders.single_value("I"),
    TaggedBlock.EFFECTS_LAYER: layer_effects.decode,
    TaggedBlock.OBJECT_BASED_EFFECTS_LAYER_INFO:
        layer_effects.decode_object_based,
    TaggedBlock.OBJECT_BASED_EFFECTS_LAYER_INFO_V0:
        layer_effects.decode_object_based,
    TaggedBlock.OBJECT_BASED_EFFECTS_LAYER_INFO_V1:
        layer_effects.decode_object_based,
    TaggedBlock.USING_ALIGNED_RENDERING: decoders.boolean("I"),
    TaggedBlock.LAYER_VERSION: decoders.single_value("I"),
    TaggedBlock.TRANSPARENCY_SHAPES_LAYER: decoders.single_value("4B"),
    TaggedBlock.LAYER_MASK_AS_GLOBAL_MASK: decoders.single_value("4B"),
Exemplo n.º 9
0
import io

from psd_tools.constants import TaggedBlock, SectionDivider
from psd_tools.decoder.actions import decode_descriptor, UnknownOSType
from psd_tools.utils import read_fmt, read_unicode_string, unpack, debug_view
from psd_tools.decoder import decoders
from psd_tools.reader.layers import Block

_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 = collections.namedtuple('SolidColorSettings', 'version data')
MetadataItem = collections.namedtuple('MetadataItem', 'sig key copy_on_sheet_duplication data')
ProtectedSetting = collections.namedtuple('ProtectedSetting', 'transparency, composite, position')
TypeToolObjectSetting = collections.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)