Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: UnsupportedMedia when input is a ".jpg" #136

Open
styper opened this issue Nov 8, 2024 · 0 comments
Open

Error: UnsupportedMedia when input is a ".jpg" #136

styper opened this issue Nov 8, 2024 · 0 comments

Comments

@styper
Copy link

styper commented Nov 8, 2024

Describe the bug
Trying to use a jpg extension image throws the message "Error: UnsupportedMedia"

To Reproduce
stegano.exe hide -i a.jpg -m "test" -o b.jpg

Expected behavior
jpg should be accepted as input, from the docs

Desktop (please complete the following information):
Release version 0.5.3
I've tested this on both Windows and Linux.

Loking at the file:

crates/stegano-core/src/media/types.rs

It appears that it's not supposed to accept "jpg" as input since it only mentions "png" and "wav":

    pub fn from_file(f: &Path) -> Result<Self> {
        if let Some(ext) = f.extension() {
            let ext = ext.to_str().unwrap().to_lowercase();
            match ext.as_str() {
                "png" => Ok(Self::Image(
                    image::open(f)
                        .map_err(|_e| SteganoError::InvalidImageMedia)?
                        .to_rgba8(),
                )),
                "wav" => {
                    let mut reader =
                        WavReader::open(f).map_err(|_e| SteganoError::InvalidAudioMedia)?;
                    let spec = reader.spec();
                    let samples: Vec<i16> = reader.samples().map(|s| s.unwrap()).collect();

                    Ok(Self::Audio((spec, samples)))
                }
                _ => Err(SteganoError::UnsupportedMedia),
            }
        } else {
            Err(SteganoError::UnsupportedMedia)
        }
    }
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant