Paul McVeigh of Quarry Road in Knockloughrim pleaded guilty to a total of 29 offences committed between January 1, 2006 and September 23, 2009.
They include making, distributing and possessing 513 indecent images of children.
McVeigh was placed on the sex offenders register for five years.
Londonderry Crown Court, sitting in Belfast, heard that the offences came to light after a computer consultant handed in memory sticks belonging to McVeigh to police.
They were found to contain 78 indecent images and police later seized the County Londonderry man's laptop and his work computer where more indecent images were discovered.
Police later established that McVeigh had distributed 186 images to other people on the internet.
A defence lawyer said McVeigh's wife left him after his arrest but she was in court along with his mother and other members of his family on Friday.
He described McVeigh as a pillar of the community who had been a member of his Gaelic football club but he had had to leave the area where he had been living.
He said McVeigh had been in a fantasy world and become more and more enmeshed in it as the years went on and it had had a catastrophic affect on his life. The lawyer said McVeigh had paid to see counsellors to help him.
Judge Piers Grant said the images, some of which were in the most serious category of child pornography, were horrific, perverted and depraved and he said it was beyond belief that anyone would want to download them.
He said the pictures had clearly robbed the children in them of their innocence.