Commit 3065366f authored by Linus K.'s avatar Linus K.
Browse files

Return DynamicImage instead of RgbImage and bump to 0.2.1

parent 91864f79
Pipeline #95 passed with stages
in 12 minutes and 53 seconds
......@@ -540,7 +540,7 @@ checksum = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084"
[[package]]
name = "mango-client"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"base64",
"bytes",
......
[package]
name = "mango-client"
version = "0.2.0"
version = "0.2.1"
authors = ["Linus <linus@cosmos-ink.net"]
edition = "2018"
......
......@@ -3,7 +3,7 @@ use std::fmt;
use crate::opds::{OpdsClient, Link};
use image;
use image::imageops::FilterType;
use image::RgbImage;
use image::DynamicImage;
fn to_owned(borrowed: &Option<&str>) -> Option<String> {
match borrowed {
......@@ -98,16 +98,15 @@ impl MangoClient {
/// Example I had (with a Ryzen 3700X):
/// - Debug: Download (2s) -> Load Image (1-2s) -> Resize Image (1-3s)
/// - Release: Download (2s) -> Load Image (1ms-60ms) -> Resize Image (15ms-40ms)
pub async fn download_thumbnail(&self, chapter: &BookChapter, max_size: Option<(u16, u16)>) -> Result<RgbImage, Box<dyn Error>> {
pub async fn download_thumbnail(&self, chapter: &BookChapter, max_size: Option<(u16, u16)>) -> Result<DynamicImage, Box<dyn Error>> {
let data = self.download_raw_thumbnail(&chapter).await?;
let mut img = image::load_from_memory(&data)?;
if let Some(max_size) = max_size {
img = img.resize(max_size.0 as u32, max_size.1 as u32, FilterType::CatmullRom);
}
let rgb = img.to_rgb();
Ok(rgb)
Ok(img)
}
/// Important: If this client has never called library() or book() before,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment