chafa icon indicating copy to clipboard operation
chafa copied to clipboard

add display for multiple images horizontally

Open acxz opened this issue 2 years ago • 6 comments

Having the ability to display multiple images in a horizontal fashion.

Right now calling multiple images with chafa defaults to a vertical layout, but it would be nice to also have a horizontal layout.

For reference, timg achieves this with the --grid flag. https://github.com/hzeller/timg/blob/cfd5f7a99401074ccfad31fa6234e94e5175074f/README.md?plain=1#L82

P.S. as a workaround currently I am using imagemagick to manually stitch the images together and then using chafa. I imagine if this step is done inside of chafa, the overall pipeline will be faster.

acxz avatar Aug 13 '22 20:08 acxz

Absolutely. It's not even that hard to add, so I could see it making the 1.14 release.

For reference, I imagine you're using something like this...

montage -tile 6x -background none -geometry 64x64+1+1 *.png - | chafa -s 80

...which is indeed very slow, and also consumes lots of memory if it's a big collection. With proper support in chafa, you could also show file names etc.

hpjansson avatar Aug 14 '22 00:08 hpjansson

This reminds me I also want something like a --fit-width switch or some other way to respect one terminal dimension while ignoring the other (as you would with tall images that're supposed to scroll vertically).

hpjansson avatar Aug 14 '22 00:08 hpjansson

For images I am using +append:

https://github.com/acxz/pokeshell/blob/52b3ec29dfb9cb9e0c3a0ed4198d9c019536e84a/bin/pokeshell#L446-L447

However, for gifs I have to do something a bit more creative: https://github.com/acxz/pokeshell/blob/52b3ec29dfb9cb9e0c3a0ed4198d9c019536e84a/bin/pokeshell#L524-L529

For gifs it is a bit more involved as I down/upsample the frames in multiple gifs to have the same number of frames in all the gifs. I essentially create a new gif stitched images that are sampled from the individual gifs.

The more this functionality can be incorporated into chafa the faster I believe my script will be.

acxz avatar Aug 14 '22 04:08 acxz

to fit width i just alias or script -s $(tput cols)

clort81 avatar Jan 20 '23 10:01 clort81

Any feedback on how I could do this? And ideally I'm after a method that would work with the various pixel types...

wabiloo avatar Feb 24 '24 14:02 wabiloo

Hi - I didn't have time to add this in 1.14, but I'll see if we can't get something going for 1.16. --fit-width is in now, though. Thanks for the interest.

hpjansson avatar Feb 25 '24 23:02 hpjansson