1
0
Fork 0
mirror of https://gitlab.com/news-flash/article_scraper.git synced 2025-07-07 16:15:32 +02:00

update deps

This commit is contained in:
Jan Lukas Gernert 2022-10-05 06:52:50 +02:00
parent 5c66930f21
commit 9fb772bfa8
2 changed files with 7 additions and 21 deletions

View file

@ -11,12 +11,12 @@ repository = "https://gitlab.com/news-flash/article_scraper"
failure = "0.1"
libxml = "0.2"
reqwest = { version = "0.11", features = ["json", "native-tls"] }
tokio = { version = "1.0", features = ["macros"] }
tokio = { version = "1.21", features = ["macros"] }
url = "2.2"
regex = "1.4"
encoding_rs = "0.8"
chrono = "0.4"
base64 = "0.13"
image = "0.23"
image = "0.24"
log = "0.4"
parking_lot = "0.11"
parking_lot = "0.12"

View file

@ -1,3 +1,4 @@
use std::io::Cursor;
use self::error::{ImageDownloadError, ImageDownloadErrorKind};
use crate::ArticleScraper;
use failure::ResultExt;
@ -213,14 +214,14 @@ impl ImageDownloader {
.context(ImageDownloadErrorKind::ImageScale)?;
image
.write_to(&mut original_image, image::ImageOutputFormat::Png)
.write_to(&mut Cursor::new(&mut original_image), image::ImageOutputFormat::Png)
.map_err(|err| {
error!("Failed to save resized image to resize");
err
})
.context(ImageDownloadErrorKind::ImageScale)?;
let dimensions = Self::get_image_dimensions(&image);
let dimensions = (image.width(), image.height());
if dimensions.0 > max_dimensions.0 || dimensions.1 > max_dimensions.1 {
image = image.resize(
max_dimensions.0,
@ -229,7 +230,7 @@ impl ImageDownloader {
);
let mut resized_buf: Vec<u8> = Vec::new();
image
.write_to(&mut resized_buf, image::ImageOutputFormat::Png)
.write_to(&mut Cursor::new(&mut resized_buf), image::ImageOutputFormat::Png)
.map_err(|err| {
error!("Failed to save resized image to resize");
err
@ -241,21 +242,6 @@ impl ImageDownloader {
Ok((original_image, resized_image))
}
fn get_image_dimensions(image: &image::DynamicImage) -> (u32, u32) {
match image {
image::DynamicImage::ImageLuma8(image) => (image.width(), image.height()),
image::DynamicImage::ImageLuma16(image) => (image.width(), image.height()),
image::DynamicImage::ImageLumaA8(image) => (image.width(), image.height()),
image::DynamicImage::ImageLumaA16(image) => (image.width(), image.height()),
image::DynamicImage::ImageRgb8(image) => (image.width(), image.height()),
image::DynamicImage::ImageRgba8(image) => (image.width(), image.height()),
image::DynamicImage::ImageRgb16(image) => (image.width(), image.height()),
image::DynamicImage::ImageRgba16(image) => (image.width(), image.height()),
image::DynamicImage::ImageBgr8(image) => (image.width(), image.height()),
image::DynamicImage::ImageBgra8(image) => (image.width(), image.height()),
}
}
async fn check_image_parent(
&self,
node: &Node,