A Dunfermline man who became obsessed with a 13-year-old girl also kept a folder of photos of children taken in Fife streets and shops.
David Johnstone had almost 14,000 indecent images of children on his computer as well as more than 400 movies, some of which included children aged between one and 14 involved in sex acts.
Johnstone, 51, called the 13-year-old girl “my perfect woman” on a file and had superimposed her image on to sex photos.
Depute fiscal Claire Bremner said he had used pictures taken perfectly innocently by other people to create sexual images.
His devices also contained a file entitled “Fife kids” which contained images taken of youngsters in shops and in the street.
Johnstone appeared from custody at Dunfermline Sheriff Court.
He admitted being in possession of indecent photographs of children at an address in Lily’s Lane.
He also admitted making indecent images of children or permitting them to be taken.
The offences occurred between August 2013 and February 2017.
Defence solicitor Brian Black said: “His position is that his obsession got out of control and he needs help.”
Sheriff Craig McSherry warned Johnstone: “It’s likely there will be a very lengthy custodial sentence.”
He called for reports and remanded Johnstone in custody until sentencing on May 30.