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
impl LibHeif
pub fn new() -> Self
sourcepub fn new_checked() -> Result<Self>
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
impl LibHeif
sourcepub fn version(&self) -> [u8; 3]
pub fn version(&self) -> [u8; 3]
Version of linked libheif
as an array of numbers in format:
[<major>, <minor>, <maintenance>]
sourcepub fn load_plugins(&self, dir_path: impl AsRef<Path>) -> Result<usize>
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.
sourcepub fn decode(
&self,
image_handle: &ImageHandle,
color_space: ColorSpace,
decoding_options: Option<DecodingOptions>
) -> Result<Image>
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.
sourcepub fn decoder_descriptors(
&self,
max_count: usize,
format_filter: Option<CompressionFormat>
) -> Vec<DecoderDescriptor<'_>>
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).
sourcepub fn encoder_descriptors(
&self,
max_count: usize,
format_filter: Option<CompressionFormat>,
name_filter: Option<&str>
) -> Vec<EncoderDescriptor<'_>>
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.
sourcepub fn encoder(&self, descriptor: EncoderDescriptor<'_>) -> Result<Encoder<'_>>
pub fn encoder(&self, descriptor: EncoderDescriptor<'_>) -> Result<Encoder<'_>>
Get an encoder instance that can be used to actually encode images from a descriptor.
sourcepub fn encoder_for_format(
&self,
format: CompressionFormat
) -> Result<Encoder<'_>>
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.