A private school maths teacher has been jailed for three years for making his own child abuse videos.
Craig Wood, 52, recorded girls as young as nine performing sex acts on webcam and exposed himself to them.
Wood, who taught at Hutchesons' Grammar School in Pollokshields, Glasgow, admitted three charges of involvement with indecent images of children.
Some of the videos were as long as two hours and involved victims the same age as the ones he taught.
Paisley Sheriff Court heard Wood was caught with nearly 1,000 indecent images of girls, aged nine to 15.
Wood, who also used to work at Renfrewshire Council-run Paisley Grammar, convinced the girls to expose themselves to him during webcam chats.
The ex-teacher was jailed and placed on the Sex Offenders' Register for life.
Sheriff Susan Sinclair condemned Wood and said he was able to abuse the children because of information he gleaned while working.
She said: "Over a period of two-and-a-half years you were able to contact females between the age of nine and 15, in the context of some form of web communication.
"In the course of which you have exposed yourself to these children and created videos of this and their participation in it, as a result of information sent by you."
She also said Wood had benefited from his experience of the online activities of youngsters, gained through his job.
Sheriff Sinclair added: "You used this knowledge to target the groups concerned.
"There is no alternative but to impose a sentence of imprisonment."
When Wood was caught police found nearly 1,000 indecent images of young girls on his computer, created using apps.
Wood chatted to girls online - then "rewarded" them for what they were doing by exposing himself to them once they had finished.
Prosecutors were unable to say how many children were involved.
Last month Wood admitted making "indecent photographs or pseudo-photographs of children" at his home in Glenburn, Paisley, between 3 August, 2014 and 23 February last year.
He also admitted charges of possessing child abuse material and forcing children to expose themselves to him.
After his arrest he was suspended and later resigned.
Wood showed no emotion as he was led away to begin his jail term.
'You cannot hide'
A spokesperson for Hutchesons' Grammar School said: "A member of staff at the secondary school was immediately suspended when we became aware of the criminal charges.
"He no longer works at the school having left last year.
"Police Scotland has advised us that our pupils and staff have not been, and are not, at risk.
"All the relevant and required checks were carried out at his time of employment.
"These were satisfactory."
Det Insp Tom Carty, of the Public Protection Unit, said: "We are committed to protecting vulnerable people.
"Those who wish to exploit young people for their own gratification will find themselves being investigated, arrested and in court.
"No matter how clever you think you are and what precautions you think you have taken to avoid detection, we will work together with our partners to take action on those who are involved in these abhorrent crimes.
"Our message is clear - if you are involved in any way in such depraved activities, then we will track you down.
"You cannot hide behind a computer."