repositories
/
dotfiles.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
69b452a
)
allow any format resize.sh
author
Mart Lubbers
<mart@martlubbers.net>
Wed, 5 Jun 2019 09:51:41 +0000
(11:51 +0200)
committer
Mart Lubbers
<mart@martlubbers.net>
Wed, 5 Jun 2019 09:51:41 +0000
(11:51 +0200)
shell/.local/bin/resize.sh
patch
|
blob
|
history
diff --git
a/shell/.local/bin/resize.sh
b/shell/.local/bin/resize.sh
index
008ef4e
..
ae36412
100755
(executable)
--- a/
shell/.local/bin/resize.sh
+++ b/
shell/.local/bin/resize.sh
@@
-1,9
+1,9
@@
#!/bin/bash
set -e
#!/bin/bash
set -e
-if [[ "$#" -ne
2
]] || ! [[ -e "$1" ]] ||\
+if [[ "$#" -ne
3
]] || ! [[ -e "$1" ]] ||\
! [[ "$2" =~ ^[0-9]+[eEpPtTgGmMkKbB]?$ ]]; then
! [[ "$2" =~ ^[0-9]+[eEpPtTgGmMkKbB]?$ ]]; then
- echo "Usage: $0
FILE TGT
" >&2
+ echo "Usage: $0
INFILE TGT OUTFILE
" >&2
echo " TGT is in bytes. Allowed suffixes: bB,kK,mM,gG,tT,pP,eE" >&2
echo " The result will be outputted to stdout. The progress to stderr" >&2
exit
echo " TGT is in bytes. Allowed suffixes: bB,kK,mM,gG,tT,pP,eE" >&2
echo " The result will be outputted to stdout. The progress to stderr" >&2
exit
@@
-40,9
+40,9
@@
while true; do
CUR=$((CUR+D*STEP))
STEP=$((STEP/2))
if [[ $PREV -eq $CUR ]]; then break; fi
CUR=$((CUR+D*STEP))
STEP=$((STEP/2))
if [[ $PREV -eq $CUR ]]; then break; fi
- if [[ $(convert "$1" -resize ${CUR}x jpg:- | wc -c) -ge $TGT ]];
+ convert "$1" -resize ${CUR}x "$3"
+ if [[ $(wc -c < "$3") -ge $TGT ]];
then D=-1; else D=1; fi
echo -n "$CUR," >&2
done
echo -e "\b " >&2
then D=-1; else D=1; fi
echo -n "$CUR," >&2
done
echo -e "\b " >&2
-convert "$1" -resize "${CUR}x" jpg:-