Compare commits
4 commits
Author | SHA1 | Date | |
---|---|---|---|
|
bd0f396305 | ||
|
3c03c47f50 | ||
|
b628ec0f4d | ||
|
6c238a03b2 |
3 changed files with 38 additions and 117 deletions
|
@ -617,18 +617,8 @@ image_loop="off"
|
|||
# Values: 'dir'
|
||||
thumbnail_dir="${XDG_CACHE_HOME:-${HOME}/.cache}/thumbnails/neofetch"
|
||||
|
||||
# Crop mode
|
||||
#
|
||||
# Default: 'normal'
|
||||
# Values: 'normal', 'fit', 'fill'
|
||||
# Flag: --crop_mode
|
||||
#
|
||||
# See this wiki page to learn about the fit and fill options.
|
||||
# https://github.com/dylanaraps/neofetch/wiki/What-is-Waifu-Crop%3F
|
||||
crop_mode="normal"
|
||||
|
||||
# Crop offset
|
||||
# Note: Only affects 'normal' crop mode.
|
||||
# Note: Only affects 'square' image size.
|
||||
#
|
||||
# Default: 'center'
|
||||
# Values: 'northwest', 'north', 'northeast', 'west', 'center'
|
||||
|
@ -637,20 +627,21 @@ crop_mode="normal"
|
|||
crop_offset="center"
|
||||
|
||||
# Image size
|
||||
# The image is half the terminal width by default.
|
||||
# NOTE: 'square' is the OLD behavior.
|
||||
# NOTE: 'auto' keeps image aspect ratio and size where possible.
|
||||
#
|
||||
# Default: 'auto'
|
||||
# Values: 'auto', '00px', '00%', 'none'
|
||||
# Values: 'auto', 'square'
|
||||
# Flags: --image_size
|
||||
# --size
|
||||
image_size="auto"
|
||||
|
||||
# Ggap between image and text
|
||||
# Gap between image and text
|
||||
#
|
||||
# Default: '3'
|
||||
# Default: '4'
|
||||
# Values: 'num', '-num'
|
||||
# Flag: --gap
|
||||
gap=3
|
||||
gap=4
|
||||
|
||||
# Image offsets
|
||||
# Only works with the w3m backend.
|
||||
|
|
119
neofetch
119
neofetch
|
@ -2667,50 +2667,32 @@ get_image_size() {
|
|||
font_width="$((term_width / columns))"
|
||||
font_height="$((term_height / lines))"
|
||||
|
||||
# Get image size.
|
||||
size="$(identify -format "%w %h" "$image")"
|
||||
width="${size%% *}"
|
||||
height="${size##* }"
|
||||
|
||||
case "$image_size" in
|
||||
"auto")
|
||||
image_size="$((columns * font_width / 2))"
|
||||
term_height="$((term_height - term_height / 4))"
|
||||
|
||||
((term_height < image_size)) && \
|
||||
image_size="$term_height"
|
||||
"square")
|
||||
width="$((columns * font_width / 2))"
|
||||
height="$width"
|
||||
;;
|
||||
|
||||
*"%")
|
||||
percent="${image_size/\%}"
|
||||
image_size="$((percent * term_width / 100))"
|
||||
|
||||
(((percent * term_height / 50) < image_size)) && \
|
||||
image_size="$((percent * term_height / 100))"
|
||||
;;
|
||||
|
||||
"none")
|
||||
# Get image size so that we can do a better crop.
|
||||
size="$(identify -format "%w %h" "$image")"
|
||||
width="${size%% *}"
|
||||
height="${size##* }"
|
||||
crop_mode="none"
|
||||
|
||||
while (( "$width" >= ("$term_width" / 2) ||
|
||||
"$height" >= "$term_height" )); do
|
||||
width="$((width / 2))"
|
||||
height="$((height / 2))"
|
||||
*)
|
||||
while (( width >= (term_width / 2) ||
|
||||
height >= (term_height / 2) )); do
|
||||
width="$((width * 10 / 15))"
|
||||
height="$((height * 10 / 15))"
|
||||
done
|
||||
;;
|
||||
|
||||
*) image_size="${image_size/px}" ;;
|
||||
esac
|
||||
|
||||
width="${width:-$image_size}"
|
||||
height="${height:-$image_size}"
|
||||
|
||||
text_padding="$((width / font_width + gap + xoffset/font_width))"
|
||||
}
|
||||
|
||||
make_thumbnail() {
|
||||
# Name the thumbnail using variables so we can
|
||||
# use it later.
|
||||
image_name="$crop_mode-$crop_offset-$width-$height-${image##*/}"
|
||||
# Name the thumbnail using variables so we can use it later.
|
||||
image_name="$image_size-$crop_offset-$width-$height-${image##*/}"
|
||||
|
||||
# Handle file extensions.
|
||||
case "${image##*.}" in
|
||||
|
@ -2722,62 +2704,17 @@ make_thumbnail() {
|
|||
# Create the thumbnail dir if it doesn't exist.
|
||||
mkdir -p "$thumbnail_dir"
|
||||
|
||||
# Check to see if the thumbnail exists before we do any cropping.
|
||||
if [[ ! -f "$thumbnail_dir/$image_name" ]]; then
|
||||
# Get image size so that we can do a better crop.
|
||||
if [[ -z "$size" ]]; then
|
||||
size="$(identify -format "%w %h" "$image")"
|
||||
og_width="${size%% *}"
|
||||
og_height="${size##* }"
|
||||
[[ ! -f "$thumbnail_dir/$image_name" ]] && \
|
||||
convert \
|
||||
"$image" \
|
||||
-strip \
|
||||
-quality 50 \
|
||||
-gravity "$crop_offset" \
|
||||
-background none \
|
||||
-sample "$width"x"$height"^ \
|
||||
-extent "$width"x"$height" \
|
||||
"$thumbnail_dir/$image_name"
|
||||
|
||||
# This checks to see if height is greater than width
|
||||
# so we can do a better crop of portrait images.
|
||||
size="$og_height"
|
||||
((og_height > og_width)) && size="$og_width"
|
||||
fi
|
||||
|
||||
case "$crop_mode" in
|
||||
"fit")
|
||||
c="$(convert "$image" \
|
||||
-colorspace srgb \
|
||||
-format "%[pixel:p{0,0}]" info:)"
|
||||
|
||||
convert \
|
||||
-background none \
|
||||
"$image" \
|
||||
-trim +repage \
|
||||
-gravity south \
|
||||
-background "$c" \
|
||||
-extent "$size"x"$size" \
|
||||
-scale "$width"x"$height" \
|
||||
"$thumbnail_dir/$image_name"
|
||||
;;
|
||||
|
||||
"fill")
|
||||
convert \
|
||||
-background none \
|
||||
"$image" \
|
||||
-trim +repage \
|
||||
-scale "$width"x"$height"^ \
|
||||
-extent "$width"x"$height" \
|
||||
"$thumbnail_dir/$image_name"
|
||||
;;
|
||||
|
||||
"none") cp "$image" "$thumbnail_dir/$image_name" ;;
|
||||
*)
|
||||
convert \
|
||||
-background none \
|
||||
"$image" \
|
||||
-gravity "$crop_offset" \
|
||||
-crop "$size"x"$size"+0+0 \
|
||||
-quality 95 \
|
||||
-scale "$width"x"$height" \
|
||||
"$thumbnail_dir/$image_name"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# The final image.
|
||||
image="$thumbnail_dir/$image_name"
|
||||
}
|
||||
|
||||
|
@ -4465,11 +4402,9 @@ ASCII:
|
|||
IMAGE:
|
||||
--loop Redraw the image constantly until Ctrl+C is used. This fixes issues
|
||||
in some terminals emulators when using image mode.
|
||||
--size 00px | --size 00% How to size the image.
|
||||
--size auto | --size square How to size the image.
|
||||
Possible values: auto, 00px, 00%, none
|
||||
--crop_mode mode Which crop mode to use
|
||||
Takes the values: normal, fit, fill
|
||||
--crop_offset value Change the crop offset for normal mode.
|
||||
--crop_offset value Change the crop offset for square mode.
|
||||
Possible values: northwest, north, northeast,
|
||||
west, center, east, southwest, south, southeast
|
||||
|
||||
|
|
13
neofetch.1
13
neofetch.1
|
@ -1,5 +1,5 @@
|
|||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.4.
|
||||
.TH NEOFETCH "1" "September 2017" "Neofetch 3.3.0" "User Commands"
|
||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.5.
|
||||
.TH NEOFETCH "1" "December 2017" "Neofetch 3.3.1-git" "User Commands"
|
||||
.SH NAME
|
||||
Neofetch \- A fast, highly customizable system info script
|
||||
.SH SYNOPSIS
|
||||
|
@ -259,16 +259,11 @@ Possible values: bar, infobar, barinfo, off
|
|||
Redraw the image constantly until Ctrl+C is used. This fixes issues
|
||||
in some terminals emulators when using image mode.
|
||||
.TP
|
||||
\fB\-\-size\fR 00px | \fB\-\-size\fR 00%
|
||||
How to size the image.
|
||||
\fB\-\-size\fR auto | \fB\-\-size\fR square How to size the image.
|
||||
Possible values: auto, 00px, 00%, none
|
||||
.TP
|
||||
\fB\-\-crop_mode\fR mode
|
||||
Which crop mode to use
|
||||
Takes the values: normal, fit, fill
|
||||
.TP
|
||||
\fB\-\-crop_offset\fR value
|
||||
Change the crop offset for normal mode.
|
||||
Change the crop offset for square mode.
|
||||
Possible values: northwest, north, northeast,
|
||||
west, center, east, southwest, south, southeast
|
||||
.TP
|
||||
|
|
Loading…
Reference in a new issue