derf / feh

a fast and light image viewer
https://feh.finalrewind.org
Other
1.52k stars 159 forks source link

Feature: load images from archives without manual extract #672

Open bobrofon opened 2 years ago

bobrofon commented 2 years ago

Hi, all.

In my day-to-day activities I sometimes work with archives of images (e.g., scans of documents, images inside backups). And I implemented a feature to work with archived images from feh without manually extracting them. I wonder if it may be useful to have this feature upstream.

The implementation is similar to cURL integration, but instead of the libcurl library, the libarchive library is used. You can check it out here: https://github.com/bobrofon/feh/tree/libarchive.

The performance with tar.gz-like archives is expectedly awful, and it's reasonable to hide archive support under an option, but with zip and rar archives it works pretty well. As a bonus, archive support makes it able to read .CBR/.CBZ/.CB7/.CBT (Comic Book Archive) file formats using feh, because they are basically archives of images.

The libarchive source code is published under the 2-clause BSD license mostly, and as I understand it, it should be compatible with feh.

What do you think about this feature? Would it be worth it to merge it into the main project?

bobrofon commented 2 years ago

Similar suggestion here: #657.

avlec commented 1 year ago

Wouldn't it be possible to just have an open archive wrapper around feh that decompresses the images and pipes them to feh's stdin?

bobrofon commented 1 year ago

Wrapper approach should work for a single file. But I don't really understand how to do something like this with multi-file archives. Well, I can extract a single file and pipe it to feh, but I cannot make a slideshow from the files, or save them as a part of a file list.

avlec commented 1 year ago

Could in the case of requiring multiple images to be loaded to create a temporary directory in /tmp or /var/tmp and extract the files there and then load that directory into feh and delete it when done or hope that your OS deletes it on reboot.

It is just going to be a lot more challenging to support decompression within feh, when a few line shell script can solve the issue. I have had this PR (#594) up for over a year now and it probably won't get in for the same reason

bobrofon commented 1 year ago

Well, yes. It is possible to unpack an archive into /tmp directory. But if I want to use this approach recursively (like feh --recursive but also search for images inside archives), it becomes a little more complex than a few lines of shell script. Also, this approach is not so useful with feh --filelist, because after a reboot, some of the files from the filelist will be deleted.

It is just going to be a lot more challenging to support decompression within feh, when a few line shell script can solve the issue. I have had this PR (https://github.com/derf/feh/pull/594) up for over a year now and it probably won't get in for the same reason

I understand that it may not be worth it to merge decompression support to feh. That's why I created a feature request and not a pull request. But if enough people are interested in this feature, I think I can simplify the implementation and unify it with libcurl implementation. And supporting libarchive will not be a challenge in this case, as long as libcurl is supported.

Good questions though.

avlec commented 1 year ago

The only other thing I can think of is mounting the archive to the filesystem through something life fuse, it seems to at least work for ZIP archives, see https://linux.die.net/man/1/fuse-zip. Not sure if they'd help with your Comic Book Archive formats, you might have to translate those to a traditional archive then mount them, or you could always implement it yourself ;) but that's definitely non-trivial

bobrofon commented 1 year ago

Actually, I thought about implementing a fuse-based filesystem that will represent regular files/directories as regular files/directories but will transform all archives into directories. But for now a relatively simple feh patch is enough for me.