Struct libheif_rs::HeifContext
source · pub struct HeifContext { /* private fields */ }Implementations§
source§impl HeifContext
impl HeifContext
sourcepub fn new() -> Result<HeifContext>
pub fn new() -> Result<HeifContext>
Create a new empty context.
sourcepub fn read_from_bytes(bytes: &[u8]) -> Result<HeifContext>
pub fn read_from_bytes(bytes: &[u8]) -> Result<HeifContext>
Create a new context from bytes.
sourcepub fn read_from_file(name: &str) -> Result<HeifContext>
pub fn read_from_file(name: &str) -> Result<HeifContext>
Create a new context from file.
sourcepub fn read_from_reader(reader: Box<dyn Reader>) -> Result<HeifContext>
pub fn read_from_reader(reader: Box<dyn Reader>) -> Result<HeifContext>
Create a new context from reader.
pub fn write_to_bytes(&self) -> Result<Vec<u8>>
pub fn write_to_file(&self, name: &str) -> Result<()>
pub fn number_of_top_level_images(&self) -> usize
pub fn top_level_image_ids(&self, item_ids: &mut [ItemId]) -> usize
pub fn image_handle(&self, item_id: ItemId) -> Result<ImageHandle>
pub fn primary_image_handle(&self) -> Result<ImageHandle>
sourcepub fn encode_image(
&mut self,
image: &Image,
encoder: &mut Encoder<'_>,
encoding_options: Option<EncodingOptions>
) -> Result<ImageHandle>
pub fn encode_image( &mut self, image: &Image, encoder: &mut Encoder<'_>, encoding_options: Option<EncodingOptions> ) -> Result<ImageHandle>
Compress the input image.
The first image added to the context is also automatically set as the primary image, but
you can change the primary image later with HeifContext::set_primary_image method.
pub fn set_primary_image( &mut self, image_handle: &mut ImageHandle ) -> Result<()>
sourcepub fn add_generic_metadata<T>(
&mut self,
master_image: &ImageHandle,
data: &[u8],
item_type: T,
content_type: Option<&str>
) -> Result<()>where
T: Into<FourCC>,
pub fn add_generic_metadata<T>( &mut self, master_image: &ImageHandle, data: &[u8], item_type: T, content_type: Option<&str> ) -> Result<()>where T: Into<FourCC>,
Add generic, proprietary metadata to an image. You have to specify
an item_type that will identify your metadata. content_type can be
an additional type.
For example, this function can be used to add IPTC metadata
(IIM stream, not XMP) to an image. Although not standard, we propose
to store IPTC data with item_type=FourCC::from(b"iptc")
and content_type=None.
sourcepub fn add_exif_metadata(
&mut self,
master_image: &ImageHandle,
data: &[u8]
) -> Result<()>
pub fn add_exif_metadata( &mut self, master_image: &ImageHandle, data: &[u8] ) -> Result<()>
Add EXIF metadata to an image.
sourcepub fn add_xmp_metadata(
&mut self,
master_image: &ImageHandle,
data: &[u8]
) -> Result<()>
pub fn add_xmp_metadata( &mut self, master_image: &ImageHandle, data: &[u8] ) -> Result<()>
Add XMP metadata to an image.
sourcepub fn set_max_decoding_threads(&mut self, max_threads: u32)
pub fn set_max_decoding_threads(&mut self, max_threads: u32)
If the maximum threads number is set to 0, the image tiles are decoded in the main thread. This is different from setting it to 1, which will generate a single background thread to decode the tiles.
Note that this setting only affects libheif itself. The codecs itself may still use multi-threaded decoding. You can use it, for example, in cases where you are decoding several images in parallel anyway you thus want to minimize parallelism in each decoder.