2019-03-24 05:37:14 +00:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
|
|
|
|
# Description: Resize images in a directory to screen resolution with imgp
|
2021-05-15 17:32:01 +00:00
|
|
|
#
|
|
|
|
# Dependencipes: imgp - https://github.com/jarun/imgp
|
2019-03-24 05:37:14 +00:00
|
|
|
#
|
|
|
|
# Notes:
|
2021-05-15 17:32:01 +00:00
|
|
|
# 1. Set res to avoid the desktop resolution prompt each time
|
|
|
|
# 2. MINSIZE is set to 1MB by default, adjust it if you want
|
|
|
|
# 3. imgp options used:
|
|
|
|
# a - adaptive mode
|
|
|
|
# c - convert PNG to JPG
|
|
|
|
# k - skip images matching specified hres/vres
|
2019-03-24 05:37:14 +00:00
|
|
|
#
|
|
|
|
# Shell: POSIX compliant
|
|
|
|
# Author: Arun Prakash Jana
|
|
|
|
|
|
|
|
# set resolution (e.g. 1920x1080)
|
2020-03-16 01:10:02 +00:00
|
|
|
res="${RESOLUTION}"
|
2019-03-24 05:37:14 +00:00
|
|
|
|
|
|
|
# set minimum image size (in bytes) to resize (default: 1MB)
|
2020-03-16 01:10:02 +00:00
|
|
|
MINSIZE="${MINSIZE:-1048576}"
|
2019-03-24 05:37:14 +00:00
|
|
|
|
|
|
|
if [ -z "$res" ]; then
|
2019-11-21 20:44:25 +00:00
|
|
|
printf "desktop resolution (hxv): "
|
|
|
|
read -r res
|
2019-03-24 05:37:14 +00:00
|
|
|
fi
|
|
|
|
|
2020-11-22 14:39:14 +00:00
|
|
|
if [ -n "$res" ] && [ -n "$MINSIZE" ]; then
|
2020-03-16 01:10:02 +00:00
|
|
|
imgp -ackx "$res" -s "$MINSIZE"
|
2019-03-24 05:37:14 +00:00
|
|
|
fi
|