Upgrade dependencies
This commit is contained in:
parent
4c598da07a
commit
bda259cf14
6 changed files with 1005 additions and 96 deletions
|
@ -1,7 +1,6 @@
|
|||
#![windows_subsystem = "windows"]
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use base64::Engine;
|
||||
use clap::{Arg, Command};
|
||||
use image::{io::Reader as ImageReader, DynamicImage};
|
||||
use log::info;
|
||||
|
@ -69,8 +68,11 @@ fn main() -> Result<()> {
|
|||
let (width, height) = image::image_dimensions(&img_path)?;
|
||||
const MAX_IMG_SIZE: u32 = 20_000_000;
|
||||
let img_data_path = if height * width > MAX_IMG_SIZE {
|
||||
// @todo utilisation de rfd au lieu de message_dialog
|
||||
// @todo Option pas de resize / taille en ligne de commande
|
||||
// @todo Option pas de resize / taille dans une config (confy)
|
||||
// @todo Demande ensergistre l’action la première fois
|
||||
// @todo Option always en ligne de commnade
|
||||
// @todo Icon
|
||||
let ratio = (height * width) as f64 / MAX_IMG_SIZE as f64;
|
||||
let new_height = (height as f64 / ratio.sqrt()) as u32;
|
||||
|
@ -106,7 +108,7 @@ fn main() -> Result<()> {
|
|||
};
|
||||
let img_data = std::fs::read(&img_data_path)?;
|
||||
tmp_dir.close()?;
|
||||
let img_base_64 = base64::engine::general_purpose::STANDARD.encode(img_data);
|
||||
let img_base_64 = bs64::encode(&img_data);
|
||||
|
||||
info!("Generate HTML");
|
||||
let html = std::str::from_utf8(Embed::get("index.html").unwrap().data.as_ref())?
|
||||
|
@ -143,11 +145,14 @@ fn main() -> Result<()> {
|
|||
|
||||
fn run_server(html: String) -> JoinHandle<()> {
|
||||
std::thread::spawn(|| {
|
||||
info!("Create runtime");
|
||||
let async_runtime = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap();
|
||||
info!("Create response");
|
||||
let hello = warp::any().map(move || warp::reply::html(html.clone()));
|
||||
info!("Launch webserver");
|
||||
async_runtime.block_on(warp::serve(hello).run(([127, 0, 0, 1], 62371)));
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue