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

Inline display of images #1301

Open
jubalh opened this issue Apr 6, 2020 · 3 comments
Open

Inline display of images #1301

jubalh opened this issue Apr 6, 2020 · 3 comments
Assignees
Labels

Comments

@jubalh
Copy link
Member

jubalh commented Apr 6, 2020

We could use @hpjansson s chafa/libchafa to display images inline.

Expected Behavior

There should be a dedicated setting for this. For example /inlineimage on|off.
When on and a user sends a URL ending in a known image format (we will have to search through each incoming message).
We download the image to a temporary location (or a general media location) and use chafa to display the picture inside Profanity.

Similar this could be done for avatars, a new /avatar view contact could be added.

Current Behavior

The URL is shown.

Possible Solution

Chafa has also sixel support. I'm not sure whether we can detect whether a terminal supports this or should make it easy and just let the user have a setting for this.
So in case sixel support is present/set we can use sixel to display the image, otherwise we use one of chafas tricks.

See https://hpjansson.org/chafa/gallery/ what chafa looks like on the terminal.

It might be helpful to look at what vifm and ranger do:
vifm/vifm@7e21fa6
ranger/ranger#1434

Example what it looks like in ranger:
ranger

@jubalh jubalh added the feature label Apr 6, 2020
@hpjansson
Copy link

I'm available to help if needed. Note that Chafa can be made to generate Unicode, ASCII or sixel output using the same API. There isn't a lot of extra work to get sixel output that way, even the dimensions are still specified in character cells.

Also, if you need extra API (for instance, ways to access canvas contents), feel free to let me know. I'm already planning to add more accessors/drawing functions, but I haven't planned out the details yet, so input is very welcome.

jubalh added a commit that referenced this issue Dec 24, 2020
First tests with libchafa for displaying pictures inline.
We choose to use ASCII art for now. Reason is that the regular method
uses color escape codes and ncurses will just print those codes and not
use the colors.

Regards #1301
@jubalh
Copy link
Member Author

jubalh commented Dec 24, 2020

@mdosch @wstrm
Anybody knows how Conversations decides whether to display an image inline?

Displaying each image inline? Sounds like you can be spammed easily. So should we do it like /url open <tab>? That you can tab through the last links with image ending and upon hitting enter just that image will be displayed?

How do we detect whether an URL actually is just an image? We would need to download it first I assume since just the file ending won't be a guarantee.

@jubalh jubalh self-assigned this Dec 24, 2020
jubalh added a commit that referenced this issue Dec 24, 2020
@mdosch
Copy link
Contributor

mdosch commented Dec 24, 2020

Afaik conversations automatically downloads from contacts in your roster if the file size is below a configurable threshold.

jubalh added a commit that referenced this issue Jan 11, 2021
First tests with libchafa for displaying pictures inline.
We choose to use ASCII art for now. Reason is that the regular method
uses color escape codes and ncurses will just print those codes and not
use the colors.

Regards #1301
jubalh added a commit that referenced this issue Jan 11, 2021
@jubalh jubalh added this to the 0.12.0 milestone Jun 29, 2021
@jubalh jubalh removed this from the 0.12.0 milestone Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants