PSDDecoder

Struct PSDDecoder 

Source
pub struct PSDDecoder<T>{ /* private fields */ }
Expand description

A simple Photoshop PSD reader.

This currently doesn’t support layer flattening but it’s useful enough in that we can extract images from it.

Further work will go onto adding a renderer that flattens image pixels. But for now this is a good basis.

Implementations§

Source§

impl<T> PSDDecoder<T>

Source

pub fn new(data: T) -> PSDDecoder<T>

Create a new decoder that reads a photoshop encoded file from T and returns pixels

§Arguments
  • data: Data source, it has to implement the `ZReaderTrait
Source

pub fn new_with_options(data: T, options: DecoderOptions) -> PSDDecoder<T>

Creates a new decoder with options that influence decoding routines

§Arguments
  • data: Data source
  • options: Custom options for the decoder
Source

pub fn decode_headers(&mut self) -> Result<(), PSDDecodeErrors>

Decode headers from the encoded image

This confirms whether the image is a photoshop image and extracts relevant information from the image including width,height and extra information.

Source

pub fn decode_raw(&mut self) -> Result<Vec<u8>, PSDDecodeErrors>

Decode an image to bytes without regard to depth or endianness

§Returns

Ok(bytes): Raw bytes of the image Err(E): An error if it occurred during decoding

Source

pub fn decode(&mut self) -> Result<DecodingResult, PSDDecodeErrors>

Decode a PSD file extracting the image only

Currently this does it without respect to layers and such, only extracting the PSD image, hence might not be the most useful one.

Source

pub const fn bit_depth(&self) -> Option<BitDepth>

Get image bit depth or None if the headers haven’t been decoded

Source

pub fn dimensions(&self) -> Option<(usize, usize)>

Get image width and height respectively or None if the headers haven’t been decoded

Source

pub fn colorspace(&self) -> Option<ColorSpace>

Get image colorspace or None if the image header hasn’t been decoded

Auto Trait Implementations§

§

impl<T> Freeze for PSDDecoder<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for PSDDecoder<T>
where T: RefUnwindSafe,

§

impl<T> Send for PSDDecoder<T>
where T: Send,

§

impl<T> Sync for PSDDecoder<T>
where T: Sync,

§

impl<T> Unpin for PSDDecoder<T>
where T: Unpin,

§

impl<T> UnwindSafe for PSDDecoder<T>
where T: UnwindSafe,

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> 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, 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.