Two drug smugglers were caught after accidentally filming themselves packing cannabis and pills into a drone which they planned to fly into Perth Prison.
Paul Reilly, 32, and Michael Martin, 35, intended to get the drugs to Martin's prisoner brother.
But the drone crashed and when police studied footage from its camera, they found images of both men.
At Perth Sheriff Court, Reilly was jailed for 33 months while Martin was sentenced to a year in prison.
The court had heard how the pair had no idea they were filming themselves as they loaded the drone with £3,000 worth of drugs hidden inside Kinder Egg sweets.
They also managed to inadvertently record the door number of the house they were operating from and a car parked outside which belonged to them.
Both Reilly, of Cumbernauld, and Martin, of Kirkcaldy, were known to police officers who identified them from the images.
Fiscal depute John Malpass told the court: "At 1 am on 22 September 2017, a prison officer was engaged in a routine patrol of the grounds and walked past A Hall towards the external wall next to the South Inch park.
"He heard a buzzing noise overhead but couldn't see anything because of the darkness. He walked the perimeter wall and noticed a drone lying on the ground with a cellophane package lying next to it."
He told the court that the crashed drone was lying below the window of the cell which Martin's brother was being held in while serving a sentence in Perth Prison.
"Police seized the drone and package. There was a camera attached to the drone and that had a micro SD card in it," Mr Malpass said.
"It was examined and showed one video file held on it.
"In the footage it is clear the drone has been switched on to try it out, but - unfortunately for those present - it was recording without the knowledge of the suspects and shows three males.
"They were later identified as Reilly, Martin and a third, as yet unidentified, male, within a bedroom of the house at 66 East March Street, Kirkcaldy.
"There was footage of Reilly wearing gloves, filling the recovered Kinder Egg with white pills and cutting up the cannabis resin into square blocks."