Goats get a lot of love on the internet. They get less in animal cognition journals.

The darlings of such research tend to be primates, whales, dolphins, dogs and horses. Goats, on the other hand, “are not considered to be the smartest cookies,” said Christian Nawroth, an agricultural scientist at the Leibniz Institute for Farm Animal Biology in Germany.

But he knows otherwise. He and his colleague found goats to be adept at reading subtle human body language. But they also found that goats are also able to distinguish happy people faces from sad ones — and they prefer happy.

The results of the study, which involved scientists observing how 20 goats reacted to pairs of black-and-white images of unfamiliar people displaying the two facial expressions, showed that goats “are even way more complex than we thought,” said co-author Natalia Albuquerque, a doctoral student at the University of Sao Paolo.

The goats spent 50 percent more time approaching and nudging the happy-face photos, and in just more than half the trials, they interacted with the happy face first, said Nawroth, the study’s lead author. They veered toward the angry one first in 30 percent, he said.

It puts goats in rare company. Other animals, such as sheep, had shown that they could recognize human faces. But only dogs and horses had previously demonstrated an ability to differentiate between expressions. Whether the finding means goats understand what emotion a human expression conveys is unknown — only dogs have proved capable of that — but it means they’ve at least got the first step in that process mastered, Albuquerque said.