[−][src]Struct psd::Psd
Represents the contents of a PSD file
PSB Support
We do not currently support PSB since the original authors didn't need it, but adding support should be trivial. If you'd like to support PSB please open an issue.
Implementations
impl Psd
[src]
pub fn from_bytes(bytes: &[u8]) -> Result<Psd, Error>
[src]
Create a Psd from a byte slice.
You'll typically get these bytes from a PSD file.
Example
let psd_bytes = include_bytes!("./my-psd-file.psd"); let psd = Psd::from_bytes(psd_bytes);
impl Psd
[src]
pub fn width(&self) -> u32
[src]
The width of the PSD file
pub fn height(&self) -> u32
[src]
The height of the PSD file
pub fn depth(&self) -> PsdDepth
[src]
The number of bits per channel
pub fn color_mode(&self) -> ColorMode
[src]
The color mode of the file
impl Psd
[src]
pub fn layers(&self) -> &Vec<PsdLayer>
[src]
Get all of the layers in the PSD
pub fn layer_by_name(&self, name: &str) -> Result<&PsdLayer, Error>
[src]
Get a layer by name
pub fn layer_by_idx(&self, idx: usize) -> Result<&PsdLayer, Error>
[src]
Get a layer by index.
index 0 is the bottom layer, index 1 is the layer above that, etc
pub fn group_by_id(&self, id: usize) -> Option<&PsdGroup>
[src]
Get a group by id.
pub fn group_by_name(&self, name: &str) -> Option<&PsdGroup>
[src]
Get a group by name
pub fn groups(&self) -> &Vec<PsdGroup>
[src]
Get all of the groups in the PSD
pub fn get_sub_layers(&self, id: usize) -> Option<&[PsdLayer]>
[src]
Returns sub layers of group by group id
pub fn flatten_layers_rgba(
&self,
filter: &dyn Fn((usize, &PsdLayer)) -> bool
) -> Result<Vec<u8>, Error>
[src]
&self,
filter: &dyn Fn((usize, &PsdLayer)) -> bool
) -> Result<Vec<u8>, Error>
Given a filter, combine all layers in the PSD that pass the filter into a vector of RGBA pixels.
We'll start from the top most layer and iterate through the pixels.
If the pixel is transparent, recursively blend it with the pixels below it until we hit an opaque pixel or we hit the bottom of the stack.
TODO: Take the layer's blend mode into account when blending layers. Right now we just use ONE_MINUS_SRC_ALPHA blending regardless of the layer.
impl Psd
[src]
pub fn rgba(&self) -> Vec<u8>
[src]
Get the RGBA pixels for the PSD [ R,G,B,A, R,G,B,A, R,G,B,A, ...]
pub fn compression(&self) -> &PsdChannelCompression
[src]
Get the compression level for the flattened image data
impl Psd
[src]
pub fn resources(&self) -> &Vec<ImageResource>
[src]
Resources from the image resources section of the PSD file
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Psd
impl Send for Psd
impl Sync for Psd
impl Unpin for Psd
impl UnwindSafe for Psd
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,