mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2025-09-24 23:41:30 +02:00
fix: take care of clippy warnings and add test image
This commit is contained in:
parent
24ebca3e8d
commit
816602fb2e
7 changed files with 37 additions and 36 deletions
|
@ -2,8 +2,9 @@ pub mod read {
|
|||
use image::{io::Reader as ImageReader, DynamicImage};
|
||||
use rpl::instructions::read::{Read, SourceType};
|
||||
|
||||
pub fn read(Read { source, format }: Read) -> DynamicImage {
|
||||
let mut img = ImageReader::open(match source {
|
||||
pub fn read(Read { source, format: _ }: Read) -> DynamicImage {
|
||||
// TODO: actual error handling
|
||||
let img = ImageReader::open(match source {
|
||||
SourceType::File(path) => path,
|
||||
})
|
||||
.expect("something went wrong :(((");
|
||||
|
@ -13,19 +14,21 @@ pub mod read {
|
|||
}
|
||||
|
||||
pub mod write {
|
||||
use image::{io::Reader as ImageReader, DynamicImage, ImageFormat};
|
||||
use image::{DynamicImage, ImageFormat};
|
||||
use rpl::instructions::write::{TargetFormat, TargetType, Write};
|
||||
|
||||
pub fn write(Write { target, format }: Write, input_data: DynamicImage) {
|
||||
input_data.save_with_format(
|
||||
match target {
|
||||
TargetType::File(path) => path,
|
||||
},
|
||||
match format {
|
||||
TargetFormat::Jpeg => ImageFormat::Jpeg,
|
||||
TargetFormat::Png => ImageFormat::Png,
|
||||
},
|
||||
);
|
||||
pub fn write(Write { target, format }: Write, input_data: &DynamicImage) {
|
||||
input_data
|
||||
.save_with_format(
|
||||
match target {
|
||||
TargetType::File(path) => path,
|
||||
},
|
||||
match format {
|
||||
TargetFormat::Jpeg => ImageFormat::Jpeg,
|
||||
TargetFormat::Png => ImageFormat::Png,
|
||||
},
|
||||
)
|
||||
.expect("couldn't save file — come back later and handle me properly please uwu");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue