mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
aea7610c76
Add image resizing on the client side to reduce load on the API
26 lines
597 B
Rust
26 lines
597 B
Rust
use image::ImageFormat;
|
|
use std::path::PathBuf;
|
|
use thiserror::Error;
|
|
|
|
#[derive(Debug, Error)]
|
|
pub enum ImageProcessingError {
|
|
#[error("failed to read image at {path}: {source}")]
|
|
Read {
|
|
path: PathBuf,
|
|
#[source]
|
|
source: std::io::Error,
|
|
},
|
|
#[error("failed to decode image at {path}: {source}")]
|
|
Decode {
|
|
path: PathBuf,
|
|
#[source]
|
|
source: image::ImageError,
|
|
},
|
|
#[error("failed to encode image as {format:?}: {source}")]
|
|
Encode {
|
|
format: ImageFormat,
|
|
#[source]
|
|
source: image::ImageError,
|
|
},
|
|
}
|