A Scottish man was on trial for farting three times during a strip search.
Police had conducted a search after the man was found with marijuana.
Police say the man smelled strongly of the drug as he was chatting to a man in a parked vehicle.
Stuart Cook, 28, had become irate when police officers told him that he would be searched.
Cook told the police “how do you like that” as he farted in their direction.
When Cook was handcuffed, his temper worsened.
Depute fiscal Lucy Simpson said Cook “deliberately farted in the direction of the officer three times, stating, ‘how do you like that?’”
Cook, from Aberdeen, Scotland, previously pleaded guilty to possession of cannabis and to behaving in a threatening or abusive manner by shouting and screaming aggressively, displaying aggressive body language, making a lewd remark towards police and “intentionally flatulating” in the direction of police.
The defense solicitor said that Cook had gotten into a minor car accident and that “he had been smoking a cannabis joint at the time and felt police overreacted in the way they dealt with him.
“He became increasingly upset with them and acted in the manner libeled.”
During the incident, Cook had “screamed expletives” and “puffed out his chest towards officers” after which he was taken to Kittybrewster police station.
Cook is due to carry out 75 hours unpaid work for deliberately breaking wind three times as he was bent over during the search.
Cook was also charged with a drug possession offense.