Entropy-sort with Linux+ImageMagick
ImageMagick 'identify' tool, which prints information about images, has a metric called 'entropy'. This measures how unpredictable your image data is, and amounts to an approximate measure of how detailed your image is.
By combining identify with a few common Linux tools like sort and xargs, I arrived at this script which sorts a list of files (piped in on stdin) by their entropy:
#!/bin/sh # sort images by entropy level, most detailed to least detailed SORTFLAGS= if [ "$1" = "r" ]; then SORTFLAGS=-r fi sed 's/$/[0]/' | tr \\n \\0 |xargs -0 identify -format "%[entropy] %i\n"| sort $SORTFLAGS|cut -d ' ' -f 2-
I use it to help sorting scanned drawings.
Notes:
Measurement of entropy is relatively slow. Entropy sort takes about 90 seconds for a collection of 100 1700px-wide scans, on my system.
For animated or layered images like GIF or TIFF, only the first frame / layer's entropy is used. (It's possible to take the average of the frames, but a) it would be proportionally slower, b) it would probably need Python or Ack, not just basic shell script, and c) it's not particularly important IMO. So I didn't bother implementing that.)









