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

Add block-image feature which forces rendering images using half blocks #228

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ cargo install spotify_player --features image

`spotify_player` also supports rendering images with `sixel` behind `sixel` feature flag, which also enables `image` feature:

To disable full resolution images rendering, `spotify_player` needs to be built with `block-image` feature enabled.
In that case, the images would be rendered using half-blocks.
This feature enables `image` feature.
```shell
cargo install spotify_player --features sixel
```
Expand Down
1 change: 1 addition & 0 deletions spotify_player/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ lyric-finder = ["lyric_finder"]
media-control = ["souvlaki", "winit"]
image = ["viuer", "dep:image"]
sixel = ["image", "viuer/sixel"]
block-image = ["image"]
notify = ["notify-rust"]
daemon = ["daemonize"]

Expand Down
2 changes: 1 addition & 1 deletion spotify_player/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ fn init_logging(cache_folder: &std::path::Path) -> Result<()> {
#[tokio::main]
async fn start_app(state: state::SharedState, is_daemon: bool) -> Result<()> {
if !is_daemon {
#[cfg(feature = "image")]
#[cfg(all(feature = "image", not(feature = "block-image")))]
{
// initialize `viuer` supports for kitty, iterm2, and sixel
viuer::get_kitty_support();
Expand Down
29 changes: 19 additions & 10 deletions spotify_player/src/ui/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,16 +287,25 @@ fn render_playback_cover_image(
let width = (rect.width as f32 * scale).round() as u32;
let height = (rect.height as f32 * scale).round() as u32;

if let Err(err) = viuer::print(
image,
&viuer::Config {
x: rect.x,
y: rect.y as i16,
width: Some(width),
height: Some(height),
..Default::default()
},
) {
#[cfg(not(feature = "block-image"))]
let config = viuer::Config {
x: rect.x,
y: rect.y as i16,
width: Some(width),
height: Some(height),
..Default::default()
};
#[cfg(feature = "block-image")]
let config = viuer::Config {
x: rect.x,
y: rect.y as i16,
width: Some(width),
height: Some(height),
use_kitty: false,
use_iterm: false,
..Default::default()
};
if let Err(err) = viuer::print(image, &config) {
tracing::error!("Failed to render the image: {err:#}",);
}
}
Expand Down
Loading