Expand description
Pure-Rust HEIF/HEIC image decoder and encoder.
let bytes = std::fs::read("photo.heic").unwrap();
let image = heifer::decode(&bytes).unwrap();
let rgba: Vec<u8> = image.to_rgba8();
println!("{}x{}, alpha: {}", image.width, image.height, image.has_alpha);
let heic = heifer::encode(&image, &heifer::EncodeOptions::default()).unwrap();
std::fs::write("copy.heic", heic).unwrap();This crate ties together the container (heifer_isobmff) and the HEVC codec
(heifer_hevc_dec, heifer_hevc_enc).
Re-exports§
pub use encode::EncodeOptions;pub use encode::encode;pub use encode::encode_hdr;pub use encode::encode_hdr_with_metadata;pub use encode::encode_rgb8;pub use encode::encode_rgba8;pub use encode::encode_with_metadata;pub use hdr::GainMap;pub use hdr::HdrImage;pub use hdr::decode_hdr;pub use hdr::read_gain_map;pub use image::Image;pub use image::Sample;pub use metadata::Exif;pub use metadata::Metadata;pub use metadata::item_metadata;pub use metadata::read_metadata;pub use heifer_hevc_dec;pub use heifer_hevc_enc;pub use heifer_isobmff;
Modules§
- color
- YCbCr to RGB conversion (ITU-T H.273 matrix coefficients).
- encode
- Encoding of HEIC files: RGB(A) images to HEVC-coded HEIF, in 8 or 10 bits.
- hdr
- HDR photos with a gain map, or a PQ/HLG transfer.
- image
- Decoded RGBA images and the geometric transforms of HEIF (crop, rotation, mirror).
- image_
crate - Integration with the
imagecrate (featureimage). - metadata
- Image metadata: EXIF, XMP and ICC profile, plus a minimal EXIF (TIFF) reader for the most common fields.
Structs§
- Options
- Decoding options.
Enums§
- Error
- Errors produced while decoding or encoding a HEIF file.
- File
Type Result - The result of
check_file_type, matchinglibheif-rs’sFileTypeResultso that a caller can switch fromlibheifwithout changing its validation logic.
Functions§
- check_
file_ type - Checks the type of a file from its leading bytes, without decoding it: the equivalent of
libheif’sheif_check_filetype, for gating or validation before a full decode. - decode
- Decodes the primary image of a HEIF/HEIC file, with its alpha channel if any, and applies the crop, rotation and mirror transforms stored in the file. Grid tiles are decoded in parallel on all available cores.
- decode_
all - Decodes every top-level image of a HEIF/HEIC file, not just the primary one.
- decode_
all_ srgb_ rgba8 - Like
decode_all, at 8 bits per sample and with the samples converted to sRGB, asdecode_srgb_rgba8does for the primary image. A file in a colour space heifer cannot convert (an ICC profile that is not an RGB input profile, or a PQ/HLG transfer) is refused withError::Unsupported. - decode_
all_ with_ options - Like
decode_all, with options. - decode_
item - Decodes one image item: coded (
hvc1) or derived (grid,iovl,iden), then applies its transformative properties. - decode_
rgba8 - Like
decode_with_options, at 8 bits per sample whatever the coded depth: half the memory, which counts on large photos. - decode_
srgb - Like
decode, with the samples converted to sRGB: from the image’s embedded ICC profile when it has one (as iPhone and many camera photos do, inDisplay P3), otherwise from itsnclxcolour information. Without either, the samples are returned as coded (asdecodedoes). - decode_
srgb_ rgba8 - Like
decode_srgb, at 8 bits per sample whatever the coded depth: half the memory, which counts on large photos (seedecode_rgba8for the caveat on 10- and 12-bit files). - decode_
srgb_ with_ options - Like
decode_srgb, with options. - decode_
thumbnail - Decodes the thumbnail of the primary image (a
thmbitem, such as the 320×240 preview of iPhone photos), orNoneif the file has none: much faster than decoding the image. - decode_
with_ options - Like
decode, with options.