From 37519f42b1bf2c0ded7a2cb27ee02de28d5f8279 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 27 May 2016 15:13:37 +1000 Subject: [PATCH] Fix issue with auto sized images --- neofetch | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/neofetch b/neofetch index 7fa7817e..58b14e0c 100755 --- a/neofetch +++ b/neofetch @@ -2229,7 +2229,9 @@ getimage () { "none") # Get image size so that we can do a better crop - getimgsize "$img" + size=$(identify -format "%w %h" "$img") + width=${size%% *} + height=${size##* } crop_mode="none" ;; @@ -2259,19 +2261,23 @@ getimage () { # Check to see if the image has a file extension, if it doesn't # then add one. case "${img##*/}" in - *"."*) imgname="$crop_mode-$crop_offset-$image_size-${img##*/}" ;; - *) imgname="$crop_mode-$crop_offset-$image_size-${img##*/}.jpg" ;; + *"."*) imgname="$crop_mode-$crop_offset-$width-$height-${img##*/}" ;; + *) imgname="$crop_mode-$crop_offset-$width-$height-${img##*/}.jpg" ;; esac # Check to see if the thumbnail exists before we do any cropping. if [ ! -f "$thumbnail_dir/$imgname" ]; then # Get image size so that we can do a better crop - getimgsize "$img" + if [ -z "$size" ]; then + size=$(identify -format "%w %h" "$img") + og_width=${size%% *} + og_height=${size##* } + fi # This checks to see if height is geater than width # so we can do a better crop of portrait images. - size=$height - [ "$height" -gt "$width" ] && size=$width + size=$og_height + [ "$og_height" -gt "$og_width" ] && size=$og_width case "$crop_mode" in fit) @@ -2348,16 +2354,6 @@ getw3m_img_path () { # }}} -# Get Image Size {{{ - -getimgsize () { - size=$(identify -format "%w %h" "$1") - width=${size%% *} - height=${size##* } -} - -# }}} - # }}}