Print a little blurhash for each image
This commit is contained in:
parent
b76c812186
commit
e97bc5a42e
18
src/main.rs
18
src/main.rs
|
@ -207,6 +207,24 @@ fn download(server: &str, args: DownloadArgs) -> Result<(), AviaryDownloadError>
|
||||||
_ => AviaryDownloadError::FilesystemError(e, dest_dir.as_ref().to_owned()),
|
_ => AviaryDownloadError::FilesystemError(e, dest_dir.as_ref().to_owned()),
|
||||||
})?;
|
})?;
|
||||||
for (indx, image) in index.images.into_iter().enumerate() {
|
for (indx, image) in index.images.into_iter().enumerate() {
|
||||||
|
|
||||||
|
// Print a little blurhash
|
||||||
|
const BH_WIDTH: u32 = 12;
|
||||||
|
const BH_HEIGHT: u32 = 5;
|
||||||
|
let blur = blurhash::decode(&image.blurhash, BH_WIDTH, BH_HEIGHT, 1.0);
|
||||||
|
let mut blur = blur.iter();
|
||||||
|
for _ in 0..BH_HEIGHT {
|
||||||
|
for _ in 0..BH_WIDTH {
|
||||||
|
let r = blur.next().unwrap();
|
||||||
|
let g = blur.next().unwrap();
|
||||||
|
let b = blur.next().unwrap();
|
||||||
|
let _ = blur.next().unwrap();
|
||||||
|
print!("\x1b[38;2;{r};{g};{b}m█");
|
||||||
|
}
|
||||||
|
print!("\n");
|
||||||
|
}
|
||||||
|
print!("\x1b[0m");
|
||||||
|
|
||||||
let extension = image.format.enum_value().map(|f| match f {
|
let extension = image.format.enum_value().map(|f| match f {
|
||||||
Format::PNG => "png",
|
Format::PNG => "png",
|
||||||
Format::WEBP => "webp",
|
Format::WEBP => "webp",
|
||||||
|
|
Loading…
Reference in a new issue