A Galashiels man is facing a prison sentence after he was caught with more than 56,000 images of youngsters being abused.
They included pictures of children as young as four being raped.
Police found the images on five different electronic devices in Colin Green’s home in Magdala Terrace.
Green, 52, pleaded guilty at Edinburgh Sheriff Court to possessing the pictures and videos between 2010 and July last year.
The court heard that forensic computer experts recovered 56,165 indecent images of children.
More than 1,300 involved children aged between four and 15 years old being raped by men.
There were 84 videos depicting child abuse, with almost half of them showing young victims being raped.
Defence lawyer Ed Hulme told the court Green had an addiction to pornography.
He will be sentenced for the offence next month.