Compare commits
2 changed files with 2 additions and 52 deletions
39
README.md
39
README.md
|
|
@ -1,39 +0,0 @@
|
||||||
# imagey
|
|
||||||
|
|
||||||
image viewer and maybe editor; inspired by mpv's simplicity
|
|
||||||
|
|
||||||
name is subject to change, suggestions welcome :)
|
|
||||||
|
|
||||||
## usage
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# try it out!
|
|
||||||
nix run git+https://git.federated.nexus/electria/imagey
|
|
||||||
|
|
||||||
# install it imperatively
|
|
||||||
nix profile install git+https://git.federated.nexus/electria/imagey
|
|
||||||
```
|
|
||||||
|
|
||||||
## known issues
|
|
||||||
|
|
||||||
### JXL
|
|
||||||
|
|
||||||
1. encoding is not implemented (jxl-oxide is decoding-only)
|
|
||||||
2. oreintation is incorrect in some cases
|
|
||||||
|
|
||||||
if the image has metadata oreintation AND
|
|
||||||
|
|
||||||
it's a jxl without the right extension OR
|
|
||||||
it's a jpeg with the jxl extension
|
|
||||||
|
|
||||||
this is due to the JXL decoder automatically rotating the image,
|
|
||||||
while the JPEG decoder (for instance) requires the extra step.
|
|
||||||
|
|
||||||
my workaround is to check the path of the input file,
|
|
||||||
not changing the oreintation if it has the jxl extension;
|
|
||||||
causing these caveats for cases where the extension is wrong.
|
|
||||||
|
|
||||||
### clipboard
|
|
||||||
|
|
||||||
1. large images (eg photos) don't seem to copy on linux/wayland,
|
|
||||||
(despite set_image not returning any error)
|
|
||||||
15
src/utils.rs
15
src/utils.rs
|
|
@ -1,6 +1,5 @@
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
ffi::OsStr,
|
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -12,7 +11,7 @@ pub fn load_image(path: impl AsRef<Path>) -> Result<RgbaImage, String> {
|
||||||
load_image_impl(path).map_err(|e| e.to_string())
|
load_image_impl(path).map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
fn load_image_impl(path: impl AsRef<Path>) -> ImageResult<RgbaImage> {
|
fn load_image_impl(path: impl AsRef<Path>) -> ImageResult<RgbaImage> {
|
||||||
let mut decoder = ImageReader::open(&path)?
|
let mut decoder = ImageReader::open(path)?
|
||||||
.with_guessed_format()?
|
.with_guessed_format()?
|
||||||
.into_decoder()?;
|
.into_decoder()?;
|
||||||
|
|
||||||
|
|
@ -20,17 +19,7 @@ fn load_image_impl(path: impl AsRef<Path>) -> ImageResult<RgbaImage> {
|
||||||
|
|
||||||
let mut decoded_image = DynamicImage::from_decoder(decoder)?;
|
let mut decoded_image = DynamicImage::from_decoder(decoder)?;
|
||||||
|
|
||||||
// the condition is a workaround to not rotate JXL images twice;
|
decoded_image.apply_orientation(oreintation);
|
||||||
// since they are already rotated by the decoder
|
|
||||||
// (while jpegs for instance aren't)
|
|
||||||
if !path
|
|
||||||
.as_ref()
|
|
||||||
.extension()
|
|
||||||
.map(OsStr::to_string_lossy)
|
|
||||||
.is_some_and(|s| s == "jxl")
|
|
||||||
{
|
|
||||||
decoded_image.apply_orientation(oreintation);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(decoded_image.into_rgba8())
|
Ok(decoded_image.into_rgba8())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue