PsdEncoder Class

Immutable settings for Adobe Photoshop encoding (Adobe Photoshop File Formats Specification): a flat document whose composite image is the image.

public sealed class PsdEncoder : ImageEncoder

Remarks

Gray pixel formats are written as a grayscale document, Cmyk32 and Cmyk64 pixels as a CMYK document (its samples stored inverted, the largest value being no ink, as the format stores them) and the others as an RGB document. 8-bit pixel formats are written with 8-bit samples, 16-bit ones with 16-bit samples, and floating-point ones (RgbaFloat, RgbaHalf exactly, through single precision) as a 32-bit document, whose samples are linear light: such an image must be labeled ColorTransferFunction.Linear (the default of floating-point images) or have an ICC profile.

An image that has a pixel that is not fully opaque gets a transparency channel, the "merged alpha" of the composite, and one layer that holds the image (named Layer 0, covering the canvas): a layer count is the only place where the format says that the channel after the colors is the transparency of the composite, and Photoshop shows the transparency of a document through its layers. As Photoshop does, the colors of the composite are stored blended over white (c × α + white × (1 − α)), which readers of the composite undo, and the layer holds the colors as they are: the colors of the composite of partly transparent 8 and 16-bit pixels come back rounded. Opaque images are written without layer and without transparency channel, as the flat documents of Photoshop (its "Background").

The file is a PSD file (version 1), or a PSB file (version 2, the large document format) when a side of the image is longer than 30,000 pixels or PsdEncoder.LargeDocument is set; a PSB file stores at most 300,000 pixels per side. The ICC profile, the EXIF profile (which carries an orientation other than ExifOrientation.TopLeft), the XMP packet and the resolution are written as image resources (1039, 1058, 1060 and 1005), with the version information (1057) that says the composite is the real image. Text entries, another CICP description than one equivalent to sRGB and the other metadata the format cannot store follow ImageEncoder.MetadataHandling (rejected by default).

A PSD file stores exactly one image: animated images and images with a poster frame are rejected with an UnsupportedImageFeatureException; use ImageFrame.Save to save one frame explicitly.

Inheritance
ImageEncoder PsdEncoder

Constructors

NameDescription
PsdEncoder()

PsdEncoder()

PsdEncoder.cs
public PsdEncoder()

No documentation is available.

Properties

NameDescription
CompressionGets the compression of the image data. Defaults to PsdCompression.RunLength.
FormatGets the format produced by this encoder.
LargeDocumentGets a value indicating whether the file is written in the large document format (a PSB file) even when the image fits a PSD file. Defaults to false: a PSB file is written only for an image with a side longer than 30,000 pixels. The extension .psb selects it.

Compression

PsdEncoder.cs

Gets the compression of the image data. Defaults to PsdCompression.RunLength.

public PsdCompression Compression { get; init; }

Property value

PsdCompression

Exceptions

ArgumentOutOfRangeException
The value is not a defined PsdCompression.

Remarks

The PackBits rows of a PSD file record their length in 16 bits: a row that compresses to more than 65,535 bytes (rows of 32-bit samples of more than about 16,000 pixels) requires PsdCompression.None or PsdEncoder.LargeDocument, and is rejected with an UnsupportedImageFeatureException otherwise.

Gets the format produced by this encoder.

public override ImageFormat Format { get; }

Property value

ImageFormat

LargeDocument

PsdEncoder.cs

Gets a value indicating whether the file is written in the large document format (a PSB file) even when the image fits a PSD file. Defaults to false: a PSB file is written only for an image with a side longer than 30,000 pixels. The extension .psb selects it.

public bool LargeDocument { get; init; }

Property value

bool