mirror of
				https://gitlab.com/comunic/comunicapiv3
				synced 2025-11-04 09:34:04 +00:00 
			
		
		
		
	Resize image only if required
This commit is contained in:
		@@ -5,7 +5,7 @@ use std::str::FromStr;
 | 
			
		||||
use actix_web::{HttpRequest, HttpResponse, web};
 | 
			
		||||
use actix_web::http::{HeaderName, HeaderValue};
 | 
			
		||||
use bytes::Bytes;
 | 
			
		||||
use image::ImageFormat;
 | 
			
		||||
use image::{GenericImageView, ImageFormat};
 | 
			
		||||
use serde::Serialize;
 | 
			
		||||
 | 
			
		||||
use crate::api_data::http_error::HttpError;
 | 
			
		||||
@@ -281,8 +281,11 @@ impl HttpRequestHandler {
 | 
			
		||||
 | 
			
		||||
        // Load image
 | 
			
		||||
        let file = self.post_file(name)?;
 | 
			
		||||
        let image = image::load_from_memory(file.buff.as_ref())?;
 | 
			
		||||
        let image = image.resize(max_w, max_h, image::imageops::FilterType::Nearest);
 | 
			
		||||
        let mut image = image::load_from_memory(file.buff.as_ref())?;
 | 
			
		||||
 | 
			
		||||
        if image.width() > max_w || image.height() > max_h {
 | 
			
		||||
            image = image.resize(max_w, max_h, image::imageops::FilterType::Nearest);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        // Determine image destination
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user