Libheif
This commit is contained in:
parent
6041ee0bc1
commit
eeb69eada0
5
Cargo.lock
generated
5
Cargo.lock
generated
|
@ -1722,12 +1722,13 @@ checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libheif-rs"
|
name = "libheif-rs"
|
||||||
version = "0.18.0"
|
version = "0.19.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "37d09b0d2d69da084eeeda9534662bc6b6096fbce3f307149750c0e572ad0ccd"
|
checksum = "749fcebc2069f334599304546cfa891c30be08cdf4f358ed984a2c71c5e0031f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"enumn",
|
"enumn",
|
||||||
"four-cc",
|
"four-cc",
|
||||||
|
"libc",
|
||||||
"libheif-sys",
|
"libheif-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -69,10 +69,10 @@ infer = "0.13.0"
|
||||||
num_cpus = "1.15.0"
|
num_cpus = "1.15.0"
|
||||||
|
|
||||||
# Heif/Heic
|
# Heif/Heic
|
||||||
libheif-rs = { version = "0.18.0", optional = true } # TODO update this, decode function is missing in this version
|
libheif-rs = { version = "0.19.2", optional = true }
|
||||||
anyhow = { version = "1.0", optional = true }
|
anyhow = { version = "1.0", optional = true }
|
||||||
|
|
||||||
state="0.5.3"
|
state = "0.5.3"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|
|
@ -11,6 +11,8 @@ use directories_next::ProjectDirs;
|
||||||
use image::{DynamicImage, ImageBuffer, Rgb};
|
use image::{DynamicImage, ImageBuffer, Rgb};
|
||||||
use imagepipe::{ImageSource, Pipeline};
|
use imagepipe::{ImageSource, Pipeline};
|
||||||
#[cfg(feature = "heif")]
|
#[cfg(feature = "heif")]
|
||||||
|
use libheif_rs::LibHeif;
|
||||||
|
#[cfg(feature = "heif")]
|
||||||
use libheif_rs::{ColorSpace, HeifContext, RgbChroma};
|
use libheif_rs::{ColorSpace, HeifContext, RgbChroma};
|
||||||
|
|
||||||
static NUMBER_OF_THREADS: state::Storage<usize> = state::Storage::new();
|
static NUMBER_OF_THREADS: state::Storage<usize> = state::Storage::new();
|
||||||
|
@ -126,9 +128,10 @@ pub fn open_cache_folder(cache_file_name: &str, save_to_cache: bool, use_json: b
|
||||||
|
|
||||||
#[cfg(feature = "heif")]
|
#[cfg(feature = "heif")]
|
||||||
pub fn get_dynamic_image_from_heic(path: &str) -> Result<DynamicImage> {
|
pub fn get_dynamic_image_from_heic(path: &str) -> Result<DynamicImage> {
|
||||||
|
let libheif = LibHeif::new();
|
||||||
let im = HeifContext::read_from_file(path)?;
|
let im = HeifContext::read_from_file(path)?;
|
||||||
let handle = im.primary_image_handle()?;
|
let handle = im.primary_image_handle()?;
|
||||||
let image = handle.decode(ColorSpace::Rgb(RgbChroma::Rgb), None)?;
|
let image = libheif.decode(&handle, ColorSpace::Rgb(RgbChroma::Rgb), None)?;
|
||||||
let width = image.width();
|
let width = image.width();
|
||||||
let height = image.height();
|
let height = image.height();
|
||||||
let planes = image.planes();
|
let planes = image.planes();
|
||||||
|
|
Loading…
Reference in a new issue