He had pleaded guilty at an earlier hearing to two offences of making indecent images of a child and one of possession of an extreme adult pornographic image.

The court heard that when police with a warrant searched Williams’ home, the indecent images were discovered stored on computer equipment.

Defending, Isobel Ascherson said that two probation reports had highlighted mental health issues affecting Williams, who also suffered with depression.

Since his arrest Williams had been attempting to tackle his problems and would welcome any offers of help, said Ms Ascherson.

Williams, who had no previous convictions, had been identified as being at low risk of re-offending, the court heard.

Judge Rupert Overbury sentenced Williams to eight months imprisonment suspended for two years. He will also have to complete 150 hours of unpaid community work and participate in a programme designed to help address his problems.