summaryrefslogtreecommitdiff
path: root/dichroism/src/image_service.rs
diff options
context:
space:
mode:
Diffstat (limited to 'dichroism/src/image_service.rs')
-rw-r--r--dichroism/src/image_service.rs18
1 files changed, 2 insertions, 16 deletions
diff --git a/dichroism/src/image_service.rs b/dichroism/src/image_service.rs
index 3a31e04..a69cca2 100644
--- a/dichroism/src/image_service.rs
+++ b/dichroism/src/image_service.rs
@@ -2,28 +2,14 @@ use crate::config::CONFIG_INSTANCE;
use crate::constants::{PHOTO_BASE_XY, PHOTO_FULLSIZE_XY, PHOTO_THUMBNAIL_XY};
use crate::error::DichroismError;
use crate::models::{Photo, PhotoSet};
-use base64::decode;
use image::imageops::FilterType;
use image::DynamicImage;
use image::GenericImageView;
-use once_cell::sync::Lazy;
-use regex::Regex;
use std::path::PathBuf;
use uuid::Uuid;
-static DATA_URI_RE: Lazy<Regex> = Lazy::new(|| {
- Regex::new("^data:image/(png|jpeg);base64,(?P<data>.+)")
- .expect("Couldn't parse data URI Regex.")
-});
-
-pub fn generate_photo_set(uri: &str) -> Result<PhotoSet, DichroismError> {
- let data = DATA_URI_RE
- .captures(uri)
- .ok_or_else(|| DichroismError::UriDataExtract("Failed to parse URI".to_string()))?
- .name("data")
- .ok_or_else(|| DichroismError::UriDataExtract("Failed to extract data".to_string()))?
- .as_str();
- let original = image::load_from_memory(&decode(data)?)?;
+pub fn generate_photo_set(data: &[u8]) -> Result<PhotoSet, DichroismError> {
+ let original = image::load_from_memory(&data)?;
let fullsize = original.resize(PHOTO_FULLSIZE_XY, PHOTO_FULLSIZE_XY, FilterType::Lanczos3);
let base = original.resize(PHOTO_BASE_XY, PHOTO_BASE_XY, FilterType::Lanczos3);