Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] draw SVG & [Feature] combine with Identify header #43

Open
tkapias opened this issue Sep 4, 2022 · 1 comment
Open

[Bug] draw SVG & [Feature] combine with Identify header #43

tkapias opened this issue Sep 4, 2022 · 1 comment

Comments

@tkapias
Copy link

tkapias commented Sep 4, 2022

[Bug] SVG

For me the image() function can't handle SVG files without conversion.

In vifmimg, I added an "svg" case which passes by a png conversion.

        "draw")
			FILE="$PWD/$6"
			image "$1" "$2" "$3" "$4" "$5" "$FILE"
			;;
        "svg")
			[ ! -f "$PCACHE" ] && \
				convert -background none "$6" "${PCACHE}.png"
			image "$1" "$2" "$3" "$4" "$5" "${PCACHE}.png"
			;;

In vifmrc:

" Images & SVG
filextype {*.bmp,*.jpg,*.jpeg,*.png,*.gif,*.xpm,*.ico,*.tif,*.svg},<image/*> {View in qimgv} qimgv %f,
fileviewer <image/svg\+xml> $HOME/.config/vifm/scripts/vifmimg svg %px %py %pw %ph %c %pc $HOME/.config/vifm/scripts/vifmimg clear
fileviewer <image/*> $HOME/.config/vifm/scripts/vifmimg draw %px %py %pw %ph %c %pc $HOME/.config/vifm/scripts/vifmimg clear

[Feature] Identify header for images

I wanted to combine the display of images and the output of "identify" as header.

In vifmimg, I added a new function image_margin_top() with a top margin of 2 Lines:

image_margin_top() {
		printf '{"action": "add", "identifier": "vifm-preview", "x": "%s", "y": "%s", "width": "%s", "height": "%s", "scaler": "contain", "path": "%s"}\n' "$2" "$(( $3 + 2 ))" "$4" "$(( $5 - 2 ))" "$6" > "$FIFO_UEBERZUG"
}

I modifies "draw" & "svg" cases to use this function and then call identify:

        "draw")
			FILE="$PWD/$6"
			image_margin_top "$1" "$2" "$3" "$4" "$5" "$FILE"
			identify "$FILE" | awk '{print $2,$3,$4,$5,$6,$7}'
			;;
        "svg")
			[ ! -f "$PCACHE" ] && \
				convert -background none "$6" "${PCACHE}.png"
			image_margin_top "$1" "$2" "$3" "$4" "$5" "${PCACHE}.png"
			identify "$PWD/$6" | awk '{print $2,$3,$4,$5,$6,$7}'
			;;

Example:

image

@tkapias
Copy link
Author

tkapias commented Sep 4, 2022

For information I wrote the same updates for ueberzug's fzfimg.sh script.

I put is in a fzf-img.sh gist, here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant