Merge pull request #266 from dylanaraps/size_none
Add '--size none' to disable cropping / resizing the images.
This commit is contained in:
commit
af8646fe66
4 changed files with 41 additions and 24 deletions
|
@ -423,7 +423,8 @@ alias fetch2="fetch \
|
|||
--image type Image source. Where and what image we display.
|
||||
Possible values: wall, ascii,
|
||||
/path/to/img, /path/to/dir/, off
|
||||
--size 20px | --size 20% Size to make the image, takes pixels or a percentage.
|
||||
--size 00px | --size 00% How to size the image.
|
||||
Possible values: auto, 00px, 00%, none
|
||||
--image_position left/right Where to display the image: (Left/Right)
|
||||
--crop_mode mode Which crop mode to use
|
||||
Takes the values: normal, fit, fill
|
||||
|
|
|
@ -324,7 +324,7 @@ crop_offset="center"
|
|||
|
||||
# Image size
|
||||
# The image is half the terminal width by default.
|
||||
# --size auto, 00px, 00%
|
||||
# --size auto, 00px, 00%, none
|
||||
image_size="auto"
|
||||
|
||||
# Right gap between image and text
|
||||
|
|
50
neofetch
50
neofetch
|
@ -351,7 +351,7 @@ crop_offset="center"
|
|||
|
||||
# Image size
|
||||
# The image is half the terminal width by default.
|
||||
# --size auto, 00px, 00%
|
||||
# --size auto, 00px, 00%, none
|
||||
image_size="auto"
|
||||
|
||||
# Right gap between image and text
|
||||
|
@ -2221,10 +2221,8 @@ getimage () {
|
|||
return
|
||||
fi
|
||||
|
||||
# Get terminal lines
|
||||
# Get terminal lines and columns
|
||||
lines=$(tput lines)
|
||||
|
||||
# Get terminal columns
|
||||
columns=$(tput cols)
|
||||
|
||||
# Calculate font size
|
||||
|
@ -2248,14 +2246,26 @@ getimage () {
|
|||
image_size=$((percent * term_height / 100))
|
||||
;;
|
||||
|
||||
"none")
|
||||
# Get image size so that we can do a better crop
|
||||
size=$(identify -format "%w %h" "$img")
|
||||
width=${size%% *}
|
||||
height=${size##* }
|
||||
crop_mode="none"
|
||||
;;
|
||||
|
||||
*) image_size=${image_size/px} ;;
|
||||
esac
|
||||
|
||||
# Fallback if width / height are empty.
|
||||
width=${width:-$image_size}
|
||||
height=${height:-$image_size}
|
||||
|
||||
# Where to draw the image
|
||||
case "$image_position" in
|
||||
"left")
|
||||
# Padding is half the terminal width + gap
|
||||
padding="\033[$((image_size / font_width + gap + xoffset/font_width))C"
|
||||
padding="\033[$((width / font_width + gap + xoffset/font_width))C"
|
||||
;;
|
||||
|
||||
"right")
|
||||
|
@ -2270,21 +2280,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
|
||||
if [ -z "$size" ]; then
|
||||
size=$(identify -format "%w %h" "$img")
|
||||
width=${size%% *}
|
||||
height=${size##* }
|
||||
og_width=${size%% *}
|
||||
og_height=${size##* }
|
||||
|
||||
# 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
|
||||
fi
|
||||
|
||||
case "$crop_mode" in
|
||||
fit)
|
||||
|
@ -2298,7 +2310,7 @@ getimage () {
|
|||
-gravity south \
|
||||
-background "$c" \
|
||||
-extent "$size"x"$size" \
|
||||
-scale "$image_size"x"$image_size" \
|
||||
-scale "$width"x"$height" \
|
||||
"$thumbnail_dir/$imgname"
|
||||
;;
|
||||
|
||||
|
@ -2306,18 +2318,19 @@ getimage () {
|
|||
convert \
|
||||
"$img" \
|
||||
-trim +repage \
|
||||
-scale "$image_size"x"$image_size"^ \
|
||||
-extent "$image_size"x"$image_size" \
|
||||
-scale "$width"x"$height"^ \
|
||||
-extent "$width"x"$height" \
|
||||
"$thumbnail_dir/$imgname"
|
||||
;;
|
||||
|
||||
none) cp "$img" "$thumbnail_dir/$imgname" ;;
|
||||
*)
|
||||
convert \
|
||||
"$img" \
|
||||
-gravity $crop_offset \
|
||||
-crop "$size"x"$size"+0+0 \
|
||||
-quality 95 \
|
||||
-scale "$image_size"x"$image_size" \
|
||||
-scale "$width"x"$height" \
|
||||
"$thumbnail_dir/$imgname"
|
||||
;;
|
||||
esac
|
||||
|
@ -2912,7 +2925,8 @@ usage () { cat << EOF
|
|||
--image type Image source. Where and what image we display.
|
||||
Possible values: wall, ascii,
|
||||
/path/to/img, /path/to/dir/, off
|
||||
--size 20px | --size 20% Size to make the image, takes pixels or a percentage.
|
||||
--size 00px | --size 00% How to size the image.
|
||||
Possible values: auto, 00px, 00%, none
|
||||
--image_position left/right Where to display the image: (Left/Right)
|
||||
--crop_mode mode Which crop mode to use
|
||||
Takes the values: normal, fit, fill
|
||||
|
@ -3209,12 +3223,12 @@ fi
|
|||
if [ "$image" != "off" ] && [ "$image" != "ascii" ]; then
|
||||
case "$image_backend" in
|
||||
"w3m")
|
||||
printf "%b%s\n" "0;1;$xoffset;$yoffset;$image_size;$image_size;;;;;$img\n4;\n3;" |\
|
||||
printf "%b%s\n" "0;1;$xoffset;$yoffset;$width;$height;;;;;$img\n4;\n3;" |\
|
||||
$w3m_img_path 2>/dev/null || padding="\033[0C"
|
||||
;;
|
||||
|
||||
"iterm2")
|
||||
printf "%b%s\a\n" "\033]1337;File=width=${image_size}px;height=${image_size}px;inline=1:$(base64 < "$img")"
|
||||
printf "%b%s\a\n" "\033]1337;File=width=${width}px;height=${height}px;inline=1:$(base64 < "$img")"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
|
|
@ -175,7 +175,9 @@ Image source. Where and what image we display.
|
|||
Possible values: wall, ascii, /path/to/img, /path/to/dir/, off
|
||||
.TP
|
||||
.B \--size 'size'
|
||||
Size to make the image, takes pixels or a percentage.
|
||||
How to size the image.
|
||||
.br
|
||||
Possible values: auto, 00px, 00%, none
|
||||
.TP
|
||||
.B \--image_position 'left/right'
|
||||
Where to display the image: (Left/Right)
|
||||
|
|
Loading…
Reference in a new issue