, - . , .
COLORS=`convert picture.jpg -format %c histogram:info:- | wc -l`
, . :
WIDTH=`jpeginfo picture.jpg | sed -r "s/.* ([0-9]+) x.*/\1/"`
HEIGHT=`jpeginfo picture.jpg | sed -r 's/.*x ([0-9]+) .*/\1/'`
.
, :
echo $WIDTH $HEIGHT $COLORS | awk '{ print $3/($1 * $2);}'
, , .
, , .
.
EDIT: , , . .
EDIT 2: , .
1: , , , ,
. .
2: "jpeginfo" "identity", jpeginfo jpg ImageMagick.
~//CheckCartoon.sh
#!/bin/sh
IMAGE=$1
COLORS=convert $IMAGE -format %c histogram:info:- | wc -l
WIDTH=<b>identify</b> $IMAGE | sed -r "s/.* ([0-9]+)x[0-9]+ .*/\1/"
HEIGHT=<b>identify</b> $IMAGE | sed -r 's/.* [0-9]+x([0-9]+) .*/\1/'
RATIO=echo $WIDTH $HEIGHT $COLORS | awk '{ print <b>($1 * $2)/$3</b>;}'
echo $RATIO | awk '{ printf "%020.5f",$1 }'
>
~//CheckAll.sh
#!/bin/sh
cd images
FILES=ls
for FILE in $FILES; do
IsIMAGE=identify $FILE 2>&1 | grep " no decode delegate " | grep -o "no"
if [ "$IsIMAGE" = "no" ]; then continue; fi
IsIMAGE=`identify $FILE 2>&1 | grep " Improper image header " | grep -o "Improper"`
if [ "$IsIMAGE" = "Improper" ]; then continue; fi
echo `.././CheckCartoon.sh $FILE` $FILE
cd..
>
.
Pic 1: ~/test/images/Cartoon-01.jpg
Pic 2: ~/test/images/Cartoon-02.png
Pic 3: ~/test/images/Cartoon-03.gif
Pic 4: ~/test/images/Real-01.jpg
. 5: ~/test/images/Real-02.jpg
. 6: ~/test/images/Real-03.jpg
http://dl.getdropbox.com/u/1961549/StackOverflow/SO1518347/Images.png
./CheckAll.sh | sort ( test). , .
00000000000003.31362 Real-03.jpg
00000000000004.61574 Real-02.jpg
00000000000009.89920 Cartoon-01.jpg
00000000000013.05870 Real-01.jpg
00000000000020.55470 Cartoon-03.gif
00000000000032.21900 Cartoon-02.png
, . 15 .
Cartoon-01.jpg - , , . Real-01.jpg - , , . , .
, , - . , , , . , .
, .