Skip to content

Commit

Permalink
support parallel image cleaning, filter more error types
Browse files Browse the repository at this point in the history
  • Loading branch information
ckuethe authored and thomasjacquin committed Oct 4, 2020
1 parent 379a4fa commit af2fcf4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions scripts/removeBadImages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ fi
# Why on G-d's green earth would I do something like this? Because for whatever
# reason, my raspberry pi produces corrupt captures occasionally and this tool
# means I get good startrails and keograms in the morning.
#
# If GNU Parallel is installed (it's not by default), then blast through and
# clean all the images as fast as possible without regard for CPU utilization.

for f in $( find "$1" -type f \( -iname image-\*.jpg -o -iname image-\*.png \) \! -ipath \*thumbnail\* ) ; do
nice convert "$f" histogram:/dev/null 2>&1 | grep -q "Corrupt JPEG" && rm -f $f
done
if which parallel > /dev/null ; then
find "$1" -type f \( -iname image-\*.jpg -o -iname image-\*.png \) \! -ipath \*thumbnail\* | \
parallel -- "convert {} histogram:/dev/null 2>&1 | egrep -q 'Huffman|Bogus|Corrupt|Invalid|Trunc|Missing' && rm -vf {}"
else
for f in $( find "$1" -type f \( -iname image-\*.jpg -o -iname image-\*.png \) \! -ipath \*thumbnail\* ) ; do
nice convert "$f" histogram:/dev/null 2>&1 | egrep -q 'Huffman|Bogus|Corrupt|Invalid|Trunc|Missing' && rm -vf $f
done
fi

0 comments on commit af2fcf4

Please sign in to comment.