pub mod parser;
pub mod converter;
mod types;
mod data;
pub use parser::{PictParser, PictVersion};
pub use converter::{PictConverter, PictToRasterOptions};
use crate::common::error::Result;
use image::ImageFormat;
pub fn convert_pict(
pict_data: &[u8],
format: ImageFormat,
width: Option<u32>,
height: Option<u32>,
) -> Result<Vec<u8>> {
let parser = PictParser::new(pict_data)?;
let options = PictToRasterOptions {
width,
height,
background_color: image::Rgba([255, 255, 255, 255]),
};
let converter = PictConverter::new(parser, options);
converter.convert_to_format(format)
}
pub fn convert_pict_to_png(
pict_data: &[u8],
width: Option<u32>,
height: Option<u32>,
) -> Result<Vec<u8>> {
convert_pict(pict_data, ImageFormat::Png, width, height)
}
pub fn convert_pict_to_jpeg(
pict_data: &[u8],
width: Option<u32>,
height: Option<u32>,
) -> Result<Vec<u8>> {
convert_pict(pict_data, ImageFormat::Jpeg, width, height)
}
pub fn convert_pict_to_webp(
pict_data: &[u8],
width: Option<u32>,
height: Option<u32>,
) -> Result<Vec<u8>> {
convert_pict(pict_data, ImageFormat::WebP, width, height)
}