use alloc::vec::Vec;
use std::fs;
use std::path::Path;
use crate::error::{Error, Result};
use crate::image::{DecodeOptions, Image};
use crate::probe::ImageInfo;
pub fn read(path: impl AsRef<Path>) -> Result<Vec<u8>> {
Ok(fs::read(path)?)
}
pub fn decode_file(path: impl AsRef<Path>, options: &DecodeOptions) -> Result<Image> {
crate::decode(&read(path)?, options)
}
pub fn probe_file(path: impl AsRef<Path>) -> Result<ImageInfo> {
crate::probe(&read(path)?)
}
pub fn looks_like_heif(bytes: &[u8]) -> bool {
match crate::ftyp::parse(bytes) {
Ok(_) => true,
Err(Error::Unsupported(_)) => bytes.len() > 8 && &bytes[4..8] == b"ftyp",
Err(_) => false,
}
}