LayerInfo

Struct LayerInfo 

Source
#[non_exhaustive]
pub struct LayerInfo {
Show 28 fields pub name: String, pub opacity: f32, pub fill_opacity: f32, pub blend_mode: String, pub x: i32, pub y: i32, pub w: u32, pub h: u32, pub image_channel_count: u16, pub image_data_rgba: Vec<u8>, pub image_data_k: Vec<u8>, pub image_data_has_g: bool, pub image_data_has_b: bool, pub image_data_has_a: bool, pub mask_channel_count: u16, pub mask_info: MaskInfo, pub image_data_mask: Vec<u8>, pub group_expanded: bool, pub group_opener: bool, pub group_closer: bool, pub funny_flag: bool, pub is_clipped: bool, pub is_alpha_locked: bool, pub is_visible: bool, pub adjustment_type: String, pub adjustment_info: Vec<f32>, pub adjustment_desc: Option<(String, Vec<(String, DescItem)>)>, pub effects_desc: Option<(String, Vec<(String, DescItem)>)>,
}
Expand description

Describes a single layer stack entry.

This data is very unorganized, and you should not use it directly in your application. You should move it out into your own types.

Returned from parse_layer_records.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: String

Name of the layer.

§opacity: f32

Normal opacity of the layer.

§fill_opacity: f32

Photoshop has separate “opacity” and “fill” sliders.

Fill opacity behaves differently for certain blend modes and when layer effects are involved.

§blend_mode: String

Blend mode stored as a string. See BlendModeDocs.

§x: i32

Global X position of the layer, based on the top left of the canvas. Can be negative. Ignored for groups.

§y: i32

Global Y position of the layer, based on the top left of the canvas. Can be negative. Ignored for groups.

§w: u32

Layer image data width.

§h: u32

Layer image data height.

§image_channel_count: u16

Number of channels in the image data.

§image_data_rgba: Vec<u8>

Four channels worth of image data. Can be RGBA or CMYA, sometimes with fewer channels. This is non-planar: a single full RGBA pixel is 4 consecutive bytes.

§image_data_k: Vec<u8>

The K channel of CMYK image data, if present.

§image_data_has_g: bool

Whether the second channel of the RGBA data came from the PSD file (true) or was synthesized (false).

If the PSD is malformed and has multiple channels of the same type, this flag might be incorrect. But on well-formed PSDs, it’s always correct.

§image_data_has_b: bool

Whether the third channel of the RGBA data came from the PSD file (true) or was synthesized (false).

If the PSD is malformed and has multiple channels of the same type, this flag might be incorrect. But on well-formed PSDs, it’s always correct.

§image_data_has_a: bool

Whether the fourth channel of the RGBA data came from the PSD file (true) or was synthesized (false).

If the PSD is malformed and has multiple channels of the same type, this flag might be incorrect. But on well-formed PSDs, it’s always correct.

§mask_channel_count: u16

Number of channels in the mask image data. They are stored planar (all of ch1, then all of ch2, etc), not interleaved like RGBA.

§mask_info: MaskInfo

Where is the mask, and how do you interpret it?

§image_data_mask: Vec<u8>

Actual mask data. Again, this is planar, unlike RGBA.

§group_expanded: bool

If this is a group opener, is the group expanded?

§group_opener: bool

Is this a group opener?

§group_closer: bool

Is this a group closer?

§funny_flag: bool

PSD layers have a “transparency shapes layer” flag. This is the inverse of that flag, i.e. “true” means “the transparency-shapes-layer flag is disabled”. This flag state is funny and does weird things to some blend modes and layer effects.

§is_clipped: bool

Does this layer have the “clipping mask” flag enabled?

§is_alpha_locked: bool

Is this layer alpha locked?

§is_visible: bool

Is this layer visible?

§adjustment_type: String

Is this an adjustment layer, and if so, what kind? Blank if not an adjustment layer.

§adjustment_info: Vec<f32>

Pile of raw, flattened adjustment layer metadata. Search // Read adjustment data. in the source code and read down from there to see how each adjustment’s data is flattened.

§adjustment_desc: Option<(String, Vec<(String, DescItem)>)>

Some adjustments use class descriptors instead of “hardcoded” data. Those adjustments get their data here.

§effects_desc: Option<(String, Vec<(String, DescItem)>)>

What effects, if any, does this layer have attached to it?

Trait Implementations§

Source§

impl Clone for LayerInfo

Source§

fn clone(&self) -> LayerInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LayerInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LayerInfo

Source§

fn default() -> LayerInfo

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.