Last active
August 29, 2015 14:04
-
-
Save andrewbigger/bb7122a91b19532804b6 to your computer and use it in GitHub Desktop.
Sample Images to number of pixels using ImageMagick
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dir=$1 | |
let max='1900000' | |
cd $dir | |
for file in `ls $dir` | |
do | |
echo "Looking at $file" | |
geometry=`identify $file | awk '{print $3}'` | |
width=`echo $geometry | sed 's/[^0-9]/ /g' | awk '{print $1}'` | |
height=`echo $geometry | sed 's/[^0-9]/ /g' | awk '{print $2}'` | |
let pix=$width*$height | |
if [ $pix -gt $max ]; then | |
echo "Resizing $file" | |
mogrify "$file" -sample @$max "$file" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment