You can get an histogram of the colours used in an image

convert RASTER2.jpg -format %c histogram:info:-
format
will return caracteristic information
%c
will return also the comments from the command
histogram
for getting the histogram
info
for getting additional info
-
the output will be via cli, it can be changed to a filename