Struct libheif_rs::HeifContext

source ·
pub struct HeifContext { /* private fields */ }

Implementations§

source§

impl HeifContext

source

pub fn new() -> Result<HeifContext>

Create a new empty context.

source

pub fn read_from_bytes(bytes: &[u8]) -> Result<HeifContext>

Create a new context from bytes.

source

pub fn read_from_file(name: &str) -> Result<HeifContext>

Create a new context from file.

source

pub fn read_from_reader(reader: Box<dyn Reader>) -> Result<HeifContext>

Create a new context from reader.

source

pub fn write_to_bytes(&self) -> Result<Vec<u8>>

source

pub fn write_to_file(&self, name: &str) -> Result<()>

source

pub fn number_of_top_level_images(&self) -> usize

source

pub fn top_level_image_ids(&self, item_ids: &mut [ItemId]) -> usize

source

pub fn image_handle(&self, item_id: ItemId) -> Result<ImageHandle>

source

pub fn primary_image_handle(&self) -> Result<ImageHandle>

source

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

source

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.

source

pub fn set_primary_image(&mut self, image_handle: &mut ImageHandle) -> Result<()>

source

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.

source

pub fn add_exif_metadata( &mut self, master_image: &ImageHandle, data: &[u8] ) -> Result<()>

Add EXIF metadata to an image.

source

pub fn add_xmp_metadata( &mut self, master_image: &ImageHandle, data: &[u8] ) -> Result<()>

Add XMP metadata to an image.

Trait Implementations§

source§

impl Drop for HeifContext

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for HeifContext

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.