cleanup: remove unneeded source format in read instruction

The image crate is able to infer the format, so that data is redundant
This commit is contained in:
Schrottkatze 2024-01-23 12:40:25 +01:00
parent 10886be00a
commit d79383a7df
Signed by: schrottkatze
GPG key ID: DFD0FD205943C14A
4 changed files with 1 additions and 10 deletions

View file

@ -2,7 +2,7 @@ pub mod read {
use image::{io::Reader as ImageReader, DynamicImage}; use image::{io::Reader as ImageReader, DynamicImage};
use ir::instruction::read::{Read, SourceType}; use ir::instruction::read::{Read, SourceType};
pub fn read(Read { source, .. }: Read) -> DynamicImage { pub fn read(Read { source }: Read) -> DynamicImage {
// TODO: actual error handling // TODO: actual error handling
let img = ImageReader::open(match source { let img = ImageReader::open(match source {
SourceType::File(path) => path, SourceType::File(path) => path,

View file

@ -4,16 +4,9 @@ use std::path::PathBuf;
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct Read { pub struct Read {
pub source: SourceType, pub source: SourceType,
pub format: SourceFormat,
} }
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum SourceType { pub enum SourceType {
File(PathBuf), File(PathBuf),
} }
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum SourceFormat {
Jpeg,
Png,
}

View file

@ -2,7 +2,6 @@
instructions: { instructions: {
0: Read(( 0: Read((
source: File("testfiles/rails.png"), source: File("testfiles/rails.png"),
format: Png,
)), )),
1: Write(( 1: Write((
target: File("testfiles/gen/out.jpg"), target: File("testfiles/gen/out.jpg"),

View file

@ -2,7 +2,6 @@
instructions: { instructions: {
0: Read(( 0: Read((
source: File("testfiles/rails.png"), source: File("testfiles/rails.png"),
format: Png,
)), )),
1: Filter(Invert), 1: Filter(Invert),
2: Write(( 2: Write((