pytoshop.image_resources

The ImageResources section.

Image resource blocks are the basic building unit of several file formats, including Photoshop’s native file format, JPEG, and TIFF. Image resources are used to store non-pixel data associated with images, such as pen tool paths.

class pytoshop.image_resources.AlphaIdentifiers(name='', identifiers=[])[source]

Bases: pytoshop.image_resources.ImageResourceBlock

data_length(header)[source]
identifiers

Alpha indentifiers

classmethod read_data(fd, resource_id, name, length, header)[source]
write_data(fd, header)[source]
class pytoshop.image_resources.BackgroundColor(name='', color_space=<ColorSpace.rgb: 0>, color=[])[source]

Bases: pytoshop.image_resources.ImageResourceBlock

Background color.

color

The color data. If the color data does not require 4 values, the extra values are undefined and should be included as zeros.

color_space

The color space. See enums.ColorSpace

data_length(header)[source]
classmethod read_data(fd, resource_id, name, length, header)[source]
write_data(fd, header)[source]
class pytoshop.image_resources.BorderInfo(name='', border_width_num=0, border_width_den=1, unit=<Units.inches: 1>)[source]

Bases: pytoshop.image_resources.ImageResourceBlock

Border information.

border_width_den

Border width denominator

border_width_num

Border width numerator

data_length(header)[source]
classmethod read_data(fd, resource_id, name, length, header)[source]
unit

Unit. See enums.Units.

write_data(fd, header)[source]
class pytoshop.image_resources.CopyrightFlag(name='', copyright=False)[source]

Bases: pytoshop.image_resources.ImageResourceBlock

copyright

Is copyrighted?

data_length(header)[source]
classmethod read_data(fd, resource_id, name, length, header)[source]
write_data(fd, header)[source]
class pytoshop.image_resources.DocumentSpecificIdsSeedNumber(name='', base_value=0)[source]

Bases: pytoshop.image_resources.ImageResourceBlock

base_value

Base value

data_length(header)[source]
classmethod read_data(fd, resource_id, name, length, header)[source]
write_data(fd, header)[source]
class pytoshop.image_resources.EffectsVisible(name='', visible=False)[source]

Bases: pytoshop.image_resources.ImageResourceBlock

data_length(header)[source]
classmethod read_data(fd, resource_id, name, length, header)[source]
visible

Are effects visible?

write_data(fd, header)[source]
class pytoshop.image_resources.GenericImageResourceBlock(name='', resource_id=0, data=b'')[source]

Bases: pytoshop.image_resources.ImageResourceBlock

data

Raw data of image resource.

data_length(header)[source]
classmethod read_data(fd, resource_id, name, length, header)[source]
resource_id

Type of image resource.

write_data(fd, header)[source]
class pytoshop.image_resources.GlobalAltitude(name='', altitude=0)[source]

Bases: pytoshop.image_resources.ImageResourceBlock

altitude

Global altitude

data_length(header)[source]
classmethod read_data(fd, resource_id, name, length, header)[source]
write_data(fd, header)[source]
class pytoshop.image_resources.GlobalAngle(name='', angle=0)[source]

Bases: pytoshop.image_resources.ImageResourceBlock

angle

Global light angle for the effect layer

data_length(header)[source]
classmethod read_data(fd, resource_id, name, length, header)[source]
write_data(fd, header)[source]
class pytoshop.image_resources.GridAndGuidesInfo(name='', grid_hori=0, grid_vert=0, guides=[])[source]

Bases: pytoshop.image_resources.ImageResourceBlock

Grid and guides resource.

data_length(header)[source]
grid_hori

Document-specific grid (horizontal). In 1/32 pt.

grid_vert

Document-specific grid (vertical). In 1/32 pt.

guides

Guides. See GuideResourceBlock.

classmethod read_data(fd, resource_id, name, length, header)[source]
version
write_data(fd, header)[source]
class pytoshop.image_resources.GuideResourceBlock(location=0, direction=<GuideDirection.vertical: 0>)[source]

Bases: object

data_length(header)[source]
direction

Guide direction. See enums.GuideDirection.

location

Location of guide in document coordinates.

classmethod read(fd, header)[source]
write(fd, header)[source]
class pytoshop.image_resources.ImageResourceBlock[source]

Bases: object

Stores a single image resource block.

pytoshop currently doesn’t deeply parse image resource blocks. The raw data is merely retained for round-tripping.

data_length(header)[source]
length(header)[source]

The length of the section, in bytes, not including its header.

name

Name of image resource.

classmethod read(fd, header)[source]

Instantiate from a file-like object.

Parameters:
  • fd (file-like object) – Must be readable, seekable and open in binary mode.
  • header (PsdFile object) – An object to get global file information from.
classmethod read_data(fd, resource_id, name, data_length, header)[source]
resource_id

Type of image resource.

total_length(header)[source]

The length of the section, in bytes, including its header.

write(fd, header)[source]

Write to a file-like object.

Parameters:
  • fd (file-like object) – Must be writable, seekable and open in binary mode.
  • header (PsdFile object) – An object to get global file information from.
write_data(fd, header)[source]
class pytoshop.image_resources.ImageResourceUnicodeString(name='', value='')[source]

Bases: pytoshop.image_resources.ImageResourceBlock

data_length(header)[source]
classmethod read_data(fd, resource_id, name, length, header)[source]
value
write_data(fd, header)[source]
class pytoshop.image_resources.ImageResources(blocks=[])[source]

Bases: object

The image resource block section.

blocks

List of all ImageResourceBlock items.

get_block(resource_id)[source]

Get the first block with the given resource id.

length(header)[source]

The length of the section, in bytes, not including its header.

classmethod read(fd, header)[source]

Instantiate from a file-like object.

Parameters:
  • fd (file-like object) – Must be readable, seekable and open in binary mode.
  • header (PsdFile object) – An object to get global file information from.
total_length(header)[source]

The length of the section, in bytes, including its header.

write(fd, header)[source]

Write to a file-like object.

Parameters:
  • fd (file-like object) – Must be writable, seekable and open in binary mode.
  • header (PsdFile object) – An object to get global file information from.
class pytoshop.image_resources.LayersGroupInfo(name='', group_ids=[])[source]

Bases: pytoshop.image_resources.ImageResourceBlock

Layers group information.

Indicates which layers are locked together.

data_length(header)[source]
group_ids
classmethod read_data(fd, resource_id, name, length, header)[source]
write_data(fd, header)[source]
class pytoshop.image_resources.PrintFlags(name='', labels=False, crop_marks=False, color_bars=False, registration_marks=False, negative=False, flip=False, interpolate=False, caption=False, print_flags=False)[source]

Bases: pytoshop.image_resources.ImageResourceBlock

Print flags.

caption
color_bars

color bars

crop_marks

crop marks

data_length(header)[source]
flip
interpolate
labels
negative
print_flags

print flags

classmethod read_data(fd, resource_id, name, length, header)[source]
registration_marks

registration marks

write_data(fd, header)[source]
class pytoshop.image_resources.PrintScale(name='', style=<PrintScaleStyle.centered: 0>, x=0.0, y=0.0, scale=0.0)[source]

Bases: pytoshop.image_resources.ImageResourceBlock

data_length(header)[source]
classmethod read_data(fd, resource_id, name, length, header)[source]
scale
style

Style. See enums.PrintScaleStyle.

write_data(fd, header)[source]
x

x location

y

y location

class pytoshop.image_resources.UnicodeAlphaNames(name='', value='')[source]

Bases: pytoshop.image_resources.ImageResourceUnicodeString

class pytoshop.image_resources.Url(name='', url=b'')[source]

Bases: pytoshop.image_resources.ImageResourceBlock

data_length(header)[source]
classmethod read_data(fd, resource_id, name, length, header)[source]
url

URL

write_data(fd, header)[source]
class pytoshop.image_resources.VersionInfo(name='', version=0, has_real_merged_data=False, writer='', reader='', file_version=0)[source]

Bases: pytoshop.image_resources.ImageResourceBlock

data_length(header)[source]
file_version

file version

has_real_merged_data

has real merged data?

classmethod read_data(fd, resource_id, name, length, header)[source]
reader

reader name

version
write_data(fd, header)[source]
writer

writer name

class pytoshop.image_resources.WorkflowUrl(name='', value='')[source]

Bases: pytoshop.image_resources.ImageResourceUnicodeString