Struct libheif_rs::LibHeif

source ·
pub struct LibHeif(/* private fields */);
Expand description

Guard structure used for libheif initialization, working with plugins, getting encoders, decode images and etc.

You may use one instance of this structure for all parts of your code. Methods of the structure use static variables inside libheif. So any changes what they will make in internals of libheif will have side effect to all instances of the structure.

For example, if you load some plugins by one LibHeif instance, all those plugins will be available to all other instances.

Implementations§

source§

impl LibHeif

source

pub fn new() -> Self

source

pub fn new_checked() -> Result<Self>

Use this method if you need to make sure that external plugins have loaded successfully.

Default paths of directories with external plugins may be changed with help of environment variable LIBHEIF_PLUGIN_PATH.

source§

impl LibHeif

source

pub fn version(&self) -> [u8; 3]

Version of linked libheif as an array of numbers in format:

[<major>, <minor>, <maintenance>]

source

pub fn load_plugins(&self, dir_path: impl AsRef<Path>) -> Result<usize>

Load all plugins from given path of directory.

Returns number of loaded plugins.

source

pub fn decode( &self, image_handle: &ImageHandle, color_space: ColorSpace, decoding_options: Option<DecodingOptions> ) -> Result<Image>

Decode an image handle into the actual pixel image and also carry out all geometric transformations specified in the HEIF file (rotation, cropping, mirroring).

If color_space is set to ColorSpace::Undefined, respectively, the original colorspace is taken.

source

pub fn decoder_descriptors( &self, max_count: usize, format_filter: Option<CompressionFormat> ) -> Vec<DecoderDescriptor<'_>>

Get a list of available decoders. You can filter the decoders by compression format.

The returned list of decoders is sorted by their priority (which is a plugin property).

source

pub fn encoder_descriptors( &self, max_count: usize, format_filter: Option<CompressionFormat>, name_filter: Option<&str> ) -> Vec<EncoderDescriptor<'_>>

Get a list of available encoders. You can filter the encoders by compression format and name.

The returned list of encoders is sorted by their priority (which is a plugin property).

Note: to get the actual encoder from the descriptors returned here, use LibHeif::encoder method.

source

pub fn encoder(&self, descriptor: EncoderDescriptor<'_>) -> Result<Encoder<'_>>

Get an encoder instance that can be used to actually encode images from a descriptor.

source

pub fn encoder_for_format( &self, format: CompressionFormat ) -> Result<Encoder<'_>>

Get an encoder for the given compression format. If there are several encoder plugins for this format, the encoder with the highest plugin priority will be returned.

Trait Implementations§

source§

impl Default for LibHeif

source§

fn default() -> Self

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

impl Drop for LibHeif

source§

fn drop(&mut self)

Executes the destructor for this 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> 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>,

§

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

§

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.