m1416
m1416

Reputation: 1087

Imagemagick GraphicsMagick image mean command

I use the following command that works in imagemagick to get the mean of a picture

identify -format "%[mean]" photo.jpg

the same command does not work under graphicsmagick. Is there an equivalent I can use?

Upvotes: 0

Views: 329

Answers (1)

Mark Setchell
Mark Setchell

Reputation: 207465

You can do this, for example:

gm identify -verbose photo.jpg | grep -E "Mean|Red|Green|Blue"

Or, if you want Red, Green and Blue as 3 separate integers

gm identify -verbose photo.jpg | awk '/Mean:/{s=s int($2) " "} END{print s}'
0 29 225

Or, if you want the average of all channels, like this:

gm identify -verbose photo.jpg | awk '/Mean:/{n++;t+=$2} END{print int(t/n)}'
85

Upvotes: 4

Related Questions