From 41e48196582eccaa56c094f3b880d6f89ff64d5d Mon Sep 17 00:00:00 2001 From: dylan araps Date: Fri, 28 Jul 2017 22:14:26 +1000 Subject: [PATCH] image: Add support for transparency when using pdf or svg as input --- CHANGELOG.md | 2 ++ neofetch | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dabe1636..bbeb487a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ ## Images - [w3m] Fixed w3m-img not found on NixOS. +- Added support for using all image types as input. + - Neofetch now supports `svg`, `tiff` etc. ## ASCII diff --git a/neofetch b/neofetch index feaa0997..d0a4f5aa 100755 --- a/neofetch +++ b/neofetch @@ -2497,7 +2497,14 @@ get_image_size() { make_thumbnail() { # Name the thumbnail using variables so we can # use it later. - image_name="$crop_mode-$crop_offset-$width-$height-${image//\//_}.jpg" + image_name="$crop_mode-$crop_offset-$width-$height-${image//'/'/_}" + + # Handle file extensions. + case "${image##*.}" in + "eps"|"pdf"|"svg"|"gif"|"png") + image_name+=".png" ;; + *) image_name+=".jpg" ;; + esac # Create the thumbnail dir if it doesn't exist. mkdir -p "$thumbnail_dir" @@ -2523,6 +2530,7 @@ make_thumbnail() { -format "%[pixel:p{0,0}]" info:)" convert \ + -background none \ "$image" \ -trim +repage \ -gravity south \ @@ -2534,6 +2542,7 @@ make_thumbnail() { "fill") convert \ + -background none \ "$image" \ -trim +repage \ -scale "$width"x"$height"^ \ @@ -2544,6 +2553,7 @@ make_thumbnail() { "none") cp "$image" "$thumbnail_dir/$image_name" ;; *) convert \ + -background none \ "$image" \ -gravity "$crop_offset" \ -crop "$size"x"$size"+0+0 \