thimc / lfimg

Image preview support for lf (list files) using Überzug
GNU General Public License v3.0
252 stars 45 forks source link

Bad image preview quality #39

Closed huibosa closed 2 years ago

huibosa commented 2 years ago

System

Windows wsl, using a 3k monitor

Terminal

wezterm, windows terminal

Description

image

cain-dev commented 2 years ago

which image previewer are you using?

huibosa commented 2 years ago

which image previewer are you using?

I don't know what the previewer is, but I have all followed the instruction of the README, so it's imagemagick or ueberzug?

cain-dev commented 2 years ago

The image quality may change based on your setup, paste your config file here so we may check. Are you using wsl?

huibosa commented 2 years ago

The image quality may change based on your setup, paste your config file here so we may check. Are you using wsl?

I'm using wsl2, ubuntu.

I insert the three set line into lfrc by hand, instead of using make command, and I have paste all other config file provide by the ropository. Here's my lfrc:

# show a waring on startup if lf is running as a nested instance
# %[ $LF_LEVEL -eq 1 ] || echo "WARNING: You're in a nested lf instance!"

#+Basic settings
set shell bash
set shellopts '-eu'
set ifs "\n"
set scrolloff 10
set drawbox
set period 1
set previewer ~/.config/lf/preview
set cleaner ~/.config/lf/cleaner
set ratios 1:2:3
# set info size:time
#-Basic settings

#+Set opener
cmd open ${{
    test -L $f && f=$(readlink -f $f)
    case $(file --mime-type $f -b) in
        text/* | application/json | inode/x-empty) $EDITOR $fx;;
        application/pdf) zathura $fx;;
        image/*) feh $fx;;
        video/*) vlc $fx;;
        *) lf -remote "send $id echo WARNING: No opener set for this file format";;
        # application/x-pie-executable) $fx;;
        # *) for f in $fx; do setsid $OPENER $f > /dev/null 2> /dev/null & done;;
    esac
}}
#-Set opener

#+Create link
# y (select for copy) and P to paste soft-link
# d (select for cut) and P to paste hard-link
cmd link %{{
    set -- $(cat ~/.local/share/lf/files)
    mode="$1"
    shift
    if [ "$#" -lt 1 ]; then
        lf -remote "send $id echo WARNING: No files to link"
        exit 0
    fi
    case "$mode" in
        # symbolically copy mode is indicating a soft link
        copy) ln -sr -t . -- "$@";;
        # while a move mode is indicating a hard link
        move) ln -t . -- "$@";;
    esac
    rm ~/.local/share/lf/files
    lf -remote "send clear"
}}
#-Create link

#+Yank file path to system clipboard
cmd yankpath &{{
    if grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null ; then
        printf '%s' "$fx" | clip.exe
    else
        printf '%s' "$fx" | xclip -i -selection clipboard
    fi

    lf -remote "send unselect"
    lf -remote "send $id echo File path copied to clipboard"
    exit 0
}}
#-Yank file path to system clipboard

#+Build options
cmd compile !{{
    set -f

    firstFile="$(echo "$fx" | cut -d' ' -f1)"
    firstFileNoExtension="${firstFile%%.*}"
    ext="${firstFile##*.}"

    case "$ext" in
        cpp) g++ $fx -o "${firstFileNoExtension}";;
        c) gcc $fx -o "${firstFileNoExtension}";;
        go) go build $f;;
        *) echo "WARNING: File format not supported";;
    esac

    lf -remote "send unselect"
}}

cmd debug !{{
    set -f

    firstFile="$(echo "$fx" | cut -d' ' -f1)"
    firstFileNoExtension="${firstFile%%.*}"
    ext="${firstFile##*.}"

    case "$ext" in
        cpp) g++ -g $fx -o "${firstFileNoExtension}";;
        c) gcc -g $fx -o "${firstFileNoExtension}";;
        *) echo "WARNING: File format not supported";;
    esac

    lf -remote "send unselect"
}}
#-Build options

#+Move to trash
%mkdir -p ~/.trash
cmd trash %{{
    for f in $fx; do
        fname="${f##*/}"
        random=$(mktemp -u)
        suffix=${random#*.}
        if [ -e ~/.trash/$fname ]; then
            fname+=".$suffix"
        fi
        mv $f ~/.trash/$fname
    done
}}
#-Move to trash

#+Archive options
cmd extract !{{
    set -f
    case "$f" in
        *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf "$f";;
        *.tar.gz|*.tgz) tar xzvf "$f";;
        *.tar.xz|*.txz) tar xJvf "$f";;
        *.zip) unzip "$f";;
        *.rar) unrar x "$f";;
        *.7z) 7z x "$f";;
        *) echo "WARNING: File format not supported";;
    esac
}}

cmd zip %zip -r "$f" "$f"
cmd tar %tar cvf "$f.tar" "$f"
cmd targz %tar cvzf "$f.tar.gz" "$f"
cmd tarbz %tar cjvf "$f.tar.bz2" "$f"
#-Archive options

#+Execute as script
cmd execute !{{
    set -f
    case "$f" in
        *.py)   /usr/bin/env python3 "$f";;
        *.sh)   /usr/bin/env bash "$f";;
        *.lua)  /usr/bin/env lua "$f";;
        *.go)   go run "$f";;
        *.c)    target=$(mktemp -u)
                gcc "$f" -o "$target"
                "$target"
                ;;
        *.cpp)  target=$(mktemp -u)
                g++ "$f" -o "$target"
                "$target"
                ;;
        *)      "$f";;
    esac
}}
#-Execute as script

#+Unmap default mappings
map w
#-Unmap default mappings

#+Archive mappings
map Cz zip
map Ct tar
map Cg targz
map Cb tarbz
map E extract
#-Archive mappings

#+Basic mappings
map <c-z> $ kill -STOP $PPID
map <c-l> reload; redraw
map <enter> shell

map A push %mkdir<space>-p<space>
map a push %touch<space>

map D trash
map P link
map Y yankpath

map X execute
map x $$f

map o &mimeopen $f
map O $mimeopen --ask $f

map Bc compile
map Bd debug

map gc cd ~/.config
map gr cd /
map gT cd ~/.trash
#-Basic mappings
cain-dev commented 2 years ago

I may be wrong but it looks like Chafa is being selected instead of uberzug, automatically happens if you are in a Wayland session. Uberzug only works on x as far as i know.

You sure you are in a x session? Could you confirm that please