brkl wrote:Okay, I installed Cygwin so I'm able to execute bash script. This method works excellently for single frames, but there's a problem with using it on a GIF animation: it orders every single color in the entire animation. Instead, I need the ordering for each frame separately. However, I suppose I can just do the order when I'm parsing the data. !
That would be the sort. To fix that you will need to somehow include the frame numebr into the histogram comment, and then replicate that into each line the first number is frame, then the rest of the color counts. That is not quite so easy, but is posible.
Hmmm a perl solution may be inorder, and perl is available under windows without needing cygwin, though is available unde cgywin too. The sort however is not available under windows (I don't think).
Code: Select all
convert rose: logo:[100x100] -colors 4 -colorspace HSL -depth 8 -format '%s\n%c' histogram:info:- |
perl -nle ' next if /^$/; $frame=$_,next if /^\d+$/; $_=$frame.$_; tr/0-9/ /cs; print;' | sort -k1n -k2rn
0 1250 24 39 68 182744 9 41176 15 2941 26 6667
0 1177 1 150 132 019684 0 392157 58 8235 51 7647
0 491 69 33 126 45217 27 0588 12 9412 49 4118
0 302 180 18 214 412 6 70 5882 7 05882 83 9216
1 6034 15 44 253 0 2 5 88235 17 2549 99 2157
1 646 167 49 74 7314 65 4902 19 2157 29 0196
1 485 9 55 179 0937 3 3 52941 21 5686 70 1961
1 335 225 35 107 1236 88 2353 13 7255 41 9608
Note perl can become very obtuse, though the above is not to bad. But I'll explain...
-n loop over each line - no final print
-l handle end of lines autoatically
-e comamnd line expression
next if /^$/; skip blank lines
$frame=$_,next if /^\d+$/; number only - note it and skip to next line
$_=$frame.$_; prepend frame number to each line
tr/0-9/ /cs; the tr-command equivelent
print; print line.
For the sort....
sort -k1n -k2rn numerically sort on first key, then numerically sort in reverse (highest first) on second key
NOTE the white really has no hue and it is the most common color in 'logo', the resize however generated an off-white as the 'best fit' color