profanity icon indicating copy to clipboard operation
profanity copied to clipboard

Inline display of images

Open jubalh opened this issue 6 years ago • 3 comments

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: https://github.com/vifm/vifm/commit/7e21fa69a5e78cdbea84b3bb6cf7cf749e99ce8f https://github.com/ranger/ranger/issues/1434

Example what it looks like in ranger: ranger

jubalh avatar Apr 06 '20 19:04 jubalh

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.

hpjansson avatar Apr 06 '20 21:04 hpjansson

@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 avatar Dec 24 '20 06:12 jubalh

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

mdosch avatar Dec 24 '20 07:12 mdosch