From 8b05a135173f789eb8ddfa0792b67417d78ad540 Mon Sep 17 00:00:00 2001 From: anon Date: Tue, 10 Dec 2024 20:39:02 +0100 Subject: [PATCH] Added 'Misc./man2png' --- Misc./man2png | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 Misc./man2png diff --git a/Misc./man2png b/Misc./man2png new file mode 100755 index 0000000..5e0cc33 --- /dev/null +++ b/Misc./man2png @@ -0,0 +1,26 @@ +#!/bin/bash +# NOTE: i gpt-ed this to show something to xolatile + +if [ "$#" -eq 0 ]; then + echo "Usage: $0 " + exit 1 +fi + +path=$(man -w "$1" 2>/dev/null) +if [ -z "$path" ]; then + echo "Manpage not found for $1" + exit 1 +fi + +if [[ "$path" =~ \.bz2$ ]]; then + decompressed=$(mktemp) + bzip2 -dc "$path" > "$decompressed" + path="$decompressed" +fi + +groff -Tpdf -mandoc "$path" > "${1}.pdf" + +magick "${1}.pdf" -density 300 -background white -alpha remove -quality 100 "${1}.png" +convert -append "${1}-*.png" "${1}.png" + +echo "Generated PNG: ${1}.png"