nikitaivanovv / ctpv Goto Github PK
View Code? Open in Web Editor NEWImage previews for lf file manager
Home Page: https://www.nikitaivanov.com/man1/ctpv
License: MIT License
Image previews for lf file manager
Home Page: https://www.nikitaivanov.com/man1/ctpv
License: MIT License
so basically I added
preview gifs .gif {{
chafa -f sixel -s "$w"x"$h" "$f"
}}
to my ctpv config
if I type ctpv filename.gif
it will work perfectly but if I try to preview the same gif with lf It will not work
I like the fast image preview for ueberzug and kitty for animated gif previews. Kitty is a bit slow when it comes to image preview compared to ueberzug
==> ERROR: One or more PGP signatures could not be verified!
I got the following error
> ctpv -s 69
cptv: ueberzug not installed
Does it requires ueberzug for running server? I want to use its kitty backend.
Hi, I have been using your project with lf and like it very much.
I am wondering if it is possible to add imv as another image thunbnail viewer? I found this project which also uses a terminal image thumbnail previewer. It supports multiple viewers including mpv
and imv
, so I am wondering if the same can be supported by ctpv
.
~ ✗ paru -S ctpv-git
:: Resolving dependencies...
:: Calculating conflicts...
:: Calculating inner conflicts...
Aur (1) ctpv-git-r146.2d36fa4-1
:: Proceed to review? [Y/n]:
:: Downloading PKGBUILDs...
PKGBUILDs up to date
nothing new to review
fetching devel info...
==> Making package: ctpv-git r146.2d36fa4-1 (Sat 02 Jul 2022 09:24:21 CEST)
==> Retrieving sources...
-> Updating ctpv git repo...
==> Validating source files with sha512sums...
ctpv ... Skipped
==> Verifying source file signatures with gpg...
ctpv git repo ... FAILED (unknown public key 6E656AC5B97B5133)
==> ERROR: One or more PGP signatures could not be verified!
error: failed to download sources for 'ctpv-git-r146.2d36fa4-1':
error: packages failed to build: ctpv-git-r146.2d36fa4-1
I use Void Linux
I installed libmagic, ImageMagick, ImageMagick-devel
I looked into #23 and I didn't find the packages mentioned there, I'm lost
thanks in advance!
info:
sudo make install
make -C embed
make[1]: Entering directory '/home/zorya/git/ctpv/embed'
make[1]: 'embed' is up to date.
make[1]: Leaving directory '/home/zorya/git/ctpv/embed'
cc -o src/ctpv.o src/ctpv.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
src/ctpv.c:2:10: fatal error: magic.h: No such file or directory
2 | #include <magic.h>
| ^~~~~~~~~
compilation terminated.
make: *** [Makefile:55: src/ctpv.o] Error 1
Looks like ueberzugpp is the successor of ueberzug.
Any way to make ctpv work with ueberzugpp?
Tried to use glow: for markdown previews.
Does not work
config is as follows:
preview glow .md {{
glow < "$f"
}}
It works when invoked via command like without lf.
Terminal : kitty
It now uses exiftool and stoped using ueberzug
I also tried opening lf in kitty but no image preview there too I did'nt change anything it was working fine before
I use archlinux and alacritty in x11(dwm)
I've already pasted the following settings (copy from repo README page) to ~/.config/lf/lfrc
:
set previewer ctpv
set cleaner ctpvclear
&ctpv -s $id
&ctpvquit $id
But when I open lf
(many times to confirm), no image preview:
So, first thing first, I need to make sure that ueberzug
works or not, then I tried to make a draw-image.sh
that uses ueberzug
to draw an image in the terminal. Here is the script content:
#!/usr/local/bin/bash
[ -z "$5" ] && echo "Usage: $0 <image> <x> <y> <max height> <max width>" && exit
source "`ueberzug library`"
ImageLayer 0< <(
ImageLayer::add [identifier]="example0" [x]="$2" [y]="$3" [max_width]="$5" [max_height]="$4" [path]="$1"
read
)
Then run it to see if it works or not:
draw-image.sh ~/Photos/wallpaper/11.jpg 0 0 100 100
And it works perfectly:
So, next try is ctpv
, here is some commands and output:
ctpv -m ~/Photos/wallpaper/rust_old.png
# .png image/png
# Based on the man page info: ` ctpv file [w] [h] [x] [y] [id]`, I tried to run this command,
# but it prints out the image binary content instead of drawing an image:
ctpv ~/Photos/wallpaper/rust_old.png 100 100 0 0
Anything I'm missing?:)
I've installed ctpv on wsl2, and follow your setup guide, but seems It's not working on wsl2.
So is it a bug, or the wsl2 hasn't been support yet?
Thank you for your work!
I used to preview file by stpv in lf. But stpv became orphaned in aur.
And I'm surprised to see ctpv and very appreciate to you!
I think it is important to preview office files for many people in job.
Can you make it preview office(docx xlsx.....etc) file like stpv with libreoffice?
Context: #12
Which package should I install on arch linux?tangk you
This error appears when I launch lf while using ctpv, I'm currently using kitty 0.28.1 and I think this error comes on versions that are higher than kitty 0.26.5 but I'm not 100% sure about it. Also I'm using icat for previews not ueberzug. Also image preview works completely fine but this error message coming up every time I launch lf is annoying and I'm not sure what's causing it to appear. Also I have tested and this error is there when I load kitty without any custom config.
Hi,
I was trying to make use of your program, however, it seems, that set forcekitty
option does not work for me.
I am running Arch, package ctpv-git
(installed today, 2022-12-09), kitty
version 0.26.5
. Kitty method of showing images by itself work (kitty +kitten icat img
as well as alias icat img
), however, when I don't have any other image previewer installed, ctpv img
prints binary garbage at me.
At first, I thought the issue might be ctpv
not picking up my config, maybe I put it into wrong location, however, I did a simple test to rule this out - installed chafa
, ctpv img
started showing images (as it should) and then I changed a line in my config to set noimages
and was back to binary garbage - as expected given chafa
exists on the system.
Thank you very much for otherwise awesome previewer, it would be great if I was able to make it work.
Btw, I'm running on sway
, so ueberzug
is not an option, since I'm a full time Wayland resident
I have openssl installed in my machine. And I am not a C dev. Help
make[1]: Leaving directory '/home/thalha/source-installed/ctpv/embed'
cc -O2 -MD -Wall -Wextra -Wno-unused-parameter -c -o src/ctpv.o src/ctpv.c
src/ctpv.c:9:10: fatal error: openssl/md5.h: No such file or directory
9 | #include <openssl/md5.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
make: *** [: src/ctpv.o] Error 1
Hi,
My setup is:
Gentoo 64bit (Multilib) / OpenRC / EloginD / Xorg-Server / Nvidia-Proprietary Drivers / newly built, updated.
Packages from Gentoo Package Manager: Latest versions of ffmpeg, ffmpegthumbnailer, ueberzug, poppler, bat, libreoffice, pdftoppm (also tried installing ueberzug with pip3).
Window Manager: DWM 6.4 (latest git version)
Terminal Emulator: Suckless ST 0.9.0 (latest git version)
LF: Just installed with native single line GO command as in its tutorial (Also tried pre-built binary).
Edited ~/.config/lf/lfrc
accordingly for ctpv.
All files are in $PATH.
I can only see text files' previews on lf. Other type of files are seen as "binary". With the same setup on Arch and Artix Linux I could have seen image previews with my own scripts. Now using my own scripts stuck on "loading" where images should be at and I can't even see text previews. With ctpv, there is no "loading" that is stuck but videos, pdfs, images are seen as "binary" files.
I am suspecting if it is related with policy, session management or any type of related stuff, since they are a little bit different in Gentoo as far as I understand. My other configs on lf work as before such as shortcuts, icons and other functions.
Any type of help is appreciated.
Thanks!
I use Debian 12 stable and lf file manager, but the file preview doesnt show. Nothing show. I use st terminal.
Cannot get image preview for .svg files.
The script for the svg can be read using ctpv not as a preview but directly from the commandline.
But it cant be previewed inside the file manager (lf in my case).
I have a book in djvu format, when I come over it in lf the memory and CPU utilizations gets very high. Checking top while doing this shows that the program that causes this is magick. So what happens is, ctpv thinks djvu files are image files (which is correct and what file --mime-type says) and tries to process them for a preview with ImageMagick. But since the file is 945 pages, it is of course a huge amount of work for ImageMagick. So I think we should find another method to produce previews for djvu files as they are a common format for (especially old) books.
Bug: https://mega.nz/file/BNMkULpZ#CkmpOk7YKSsn6PU84T5RisuUouUHp53b2Uzat83cPyw
You should remove the cmd
prefix for the new version of lf (r27), otherwise the command will not work
set previewer ctpv
set cleaner ctpvclear
&ctpv -s $id
on-quit $ctpv -e $id
You should also update the documentation in lf -> https://github.com/gokcehan/lf/wiki/Previews#with-stpv-and-ctpv
System
kitty: version 0.25.2 created by Kovid Goyal
lf: version r27
OS: Arch Linux x86_64 5.18.10-zen1-1-zen
WM: sway v1.7
error shown whenever lf is opened : "preview: value should be empty, 'true', or 'false'"
I am using personal fork of ST if it helps
Note: I tried it on kitty terminal as well, same problem. I dont think its the terminal's problem.
Not using wayland, and the arch signature is not trusted atm
Thanks anyway
Hi,
lf on wayland uses chafa not ueberzug, thus the preview has low resolution.
Changing the login to Xorg it seems to use ueberzug and preview has good resolution.
But I don't know what software is causing the issue.
Where is the problem? On ueberzug, on wayland, on lf or on ctpv?
In case when users use LibreOffice from app images, they might not have poppler installed. It would be nice to go through LibreOffice as second option
Please, use one of the two syntaxes for invocation:
source-highlight [OPTIONS]... -i input_file -o output_file
source-highlight [OPTIONS]... [FILES]...
Sorry in advance. Maybe I missed something, but is this not supported? Using lf on macos. Libreoffice was installed with homebrew. I do have microsoft Office installed, but i manually set priority to libreoffice in the ctpv config file.
Lf just shows "binary" where preview should be. When I call ctpv in terminal (kitty) to one of these files (docx, pptx, xlsx) I get the following in the attached screenshot
Output: ctpv: config:1:18: unexpected token: {{, expected: /
Config:
preview arsz .7z {{
7z l "$f"
}}
hello guys. saw some cool snippets in #20, but I have a problem with this one:
preview audio audio/* {{
audio() {
ffmpegthumbnailer -i "$f" -s 256 -o "$cache_f" 2>/dev/null
}
if exists ffmpeg; then
x="$(ffmpeg -hide_banner -i "$f" 2>&1)"
printf '%s\n' "$x"
y=$((y + $(printf '%s\n' "$x" | wc -l)))
fi
convert_and_show_image audio
}}
cover position is awful. and there's enough space for it under metadata, so I don't know why cover is not placed there.
I drew the position where I want it to be (square with question mark inside it)
also there's "At least one output file must be specified" in the end of metadata. maybe use ffprobe for metadata gathering?
08:48:06 alex@alex-xps ctpv ±|master|→ sudo make install
make -C embed
make[1]: Entering directory '/home/alex/ctpv/embed'
make[1]: 'embed' is up to date.
make[1]: Leaving directory '/home/alex/ctpv/embed'
cc -o src/ctpv.o src/ctpv.c -c -O2 -MD -Wall -Wextra -Wno-unused-parameter
src/ctpv.c:2:10: fatal error: magic.h: No such file or directory
2 | #include <magic.h>
| ^~~~~~~~~
compilation terminated.
make: *** [Makefile:55: src/ctpv.o] Error 1
Line 1 in 6d5c14d
Is there a reason fixing prefix to /usr/bin
, or it's possible to be a pass-in option? I would really like it to be a local only program, cause people don't have sudo privilege all the time.
Thanks for the great work!
Hello, I've recently started working in a replacement for Ueberzug after its demise. ueberzugpp
It works OOB with ctpv and other software that previously used og ueberzug. But one feature that I added that wasn't in OG Ueberzug doesn't work, that being sixel output.
In ranger, sixel output works with some changes, particularly, connecting ueberzug's stdout to python's.
self.process = Popen(['ueberzug', 'layer', '--silent'],
stderr=PIPE, stdout=sys.stdout.buffer,
cwd=self.working_dir, universal_newlines=True)
(sample of sixel output working on wezterm/sixel)
sadly, the same can't be said for lf, as no output is being generated.
One way to fix this is to connect ctpv's (or is this an lf issue?) stdout to ueberzugpp's. I tried to do it on my own but you understand this codebase more than I do.
I'd be grateful if you could make this changes as they would keep compatibility with OG ueberzug and also add support for ueberzugpp.
Hello,
At first, thank you very much for the project, I used it with the kitty terminal in the lf file manager.
After a certain time, presumably an update, ctpv throws this error (title) after running
ctpv /path/to/image
Note that I don't use any flags and only point to one image.
But when I actually run the flag:
ctpv --place /path/to/image
it throws:
ctpv: invalid option -- '-'
I cannot install ctpv, because get error message:
$ sudo make install
make -C embed
make[1]: Entering directory '/home/shyciii/ctpv/embed'
make[1]: 'embed' is up to date.
make[1]: Leaving directory '/home/shyciii/ctpv/embed'
cc -o src/ctpv.o src/ctpv.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
src/ctpv.c:2:10: fatal error: magic.h: No such file or directory
2 | #include <magic.h>
| ^~~~~~~~~
compilation terminated.
make: *** [Makefile:55: src/ctpv.o] Error 1
Preview doesn't work with files that have multiple dots in the file name. If I have a file with the name archlinux.ios.torrent the preview will not work but if I rename the same file to archlinux.torrent the preview works fine.
Fail to compile in FreebSD
:
doas gmake install
# cc -o src/config.o src/config.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# gmake -C embed
# gmake[1]: Entering directory '/usr/home/wison/temp/ctpv/embed'
# cc embed.c -o embed
# gmake[1]: Leaving directory '/usr/home/wison/temp/ctpv/embed'
# mkdir -p gen
# embed/embed -p prev_scr_ sh/prev/any.sh sh/prev/atool.sh sh/prev/audio.sh sh/prev/bat.sh sh/prev/cat.sh sh/prev/colordiff.sh sh/prev/delta.sh sh/prev/diff_so_fancy.sh sh/prev/elinks.sh sh/prev/font.sh sh/prev/gpg.sh sh/prev/highlight.sh sh/prev/image.sh sh/prev/jq.sh sh/prev/libreoffice.sh sh/prev/ls.sh sh/prev/lynx.sh sh/prev/mdcat.sh sh/prev/pdf.sh sh/prev/source_highlight.sh sh/prev/svg.sh sh/prev/symlink.sh sh/prev/torrent.sh sh/prev/video.sh sh/prev/w3m.sh > gen/previews.h
# cc -o src/ctpv.o src/ctpv.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# cc -o src/error.o src/error.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# cc -o src/lexer.o src/lexer.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# cc -o src/preview.o src/preview.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# embed/embed -p scr_ sh/clear.sh sh/end.sh > gen/server.h
# cc -o src/server.o src/server.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# embed/embed -p scr_ sh/helpers.sh > gen/helpers.h
# cc -o src/shell.o src/shell.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# cc -o src/ulist.o src/ulist.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# cc -o src/utils.o src/utils.c -c -O2 -MMD -Wall -Wextra -Wno-unused-parameter
# src/utils.c:165:20: warning: implicit declaration of function 'signal' is invalid in C99 [-Wimplicit-function-declaration]
# ERRCHK_RET_ERN(signal(sig, handler) == SIG_ERR);
# ^
# src/utils.c:165:44: error: use of undeclared identifier 'SIG_ERR'
# ERRCHK_RET_ERN(signal(sig, handler) == SIG_ERR);
# ^
# 1 warning and 1 error generated.
# gmake: *** [Makefile:55: src/utils.o] Error 1
Then I try search in the whole source files:
rg SIG_ERR
# src/utils.c
# 165: ERRCHK_RET_ERN(signal(sig, handler) == SIG_ERR);
Is it the SIG_ERR
defines in OS source code somehow like a constant? or you just miss it ? :)
OS version:
uname -a
# FreeBSD my-bsd 13.1-RELEASE-p3 FreeBSD 13.1-RELEASE-p3 GENERIC amd64
I looked up, and it seems there is no support for dark PDF preview like in stpv:
DARK_DOCS= # invert documents preview color in image previews
https://github.com/Naheel-Azawy/stpv/blob/5c6058cc4afe289bdcb89bc0eaab84bd1df8f14d/stpv#L282-L286:
if [ -n "$is_doc" ] && [ -n "$DARK_DOCS" ]; then
dark_opts='-channel RGB -negate'
else
dark_opts=
fi
https://github.com/Naheel-Azawy/stpv/blob/5c6058cc4afe289bdcb89bc0eaab84bd1df8f14d/stpv#L300-L306:
# shellcheck disable=SC2086
convert "${conv_file}[0]" \
$dark_opts \
$auto_orient_opts \
$max_img_size_opts \
-resize ${width}x${height} \
"$image_cache_path"
I'm not familiar with pdftoppm
's options, but it looks like there is no way to invert colors. Maybe it's better to switch to convert
instead of pdftoppm
for PDF files? Or add a second way to preview PDF files and also set the priority: convert
> pdftoppm
.
Could you tell me what package provides this lib? I just got a compile error saying i'm missing this.
I did some searching, but there were several results, including some kernel library.
It keeps showing "Loading..." . Does it usually have to take a long time?
The last tagged release is -right now- 50 commits behind. Using this release is obviously not really ideal, as all the progress from these 50 commits would go to waste.
I use nixos, which makes your OS deterministic, thus directly installing from the tip of your master branch is impossible. That's why we specify the release version directly. Using a release over a commit hash is preferred because it leaves the control to decide which features get packaged by the developer
Please tag a new release on a stable commit to allows us to package a slightly newer version.
Hi, great program. Really easily makes lf into the best terminal file manager.
PDF image previews aren't working for me due to pdftoppm complaining about flags. I was able to fix it in my case by removing "-tiffcompression jpeg" from "ctvp/sh/prev/pdf.sh".
I'm building it from source on gentoo linux. Anyway, thought I would let you know. Godspeed Ivanov.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.