A Brooklyn guidance counselor on Wednesday was sentenced to 5 years in prison — the maximum — for trading in child pornography, federal prosecutors said.

After his prison term, John Capuano, 44, of Valley Stream, will spend a decade under supervised release, be registered as a sex offender, and be barred from any unsupervised contact with minors, Bridget M. Rohde, acting United States attorney for the Eastern District of New York, said in a statement.

Capuano’s role as a guidance counselor in New York State required him to report child abuse, she said.

“Instead, he victimized children by sharing images of their rape and abuse with others online,” Rohde said. Protecting children is a top priority for her office, she added.

Until his arrest on May 28, 2015, Capuano worked in School District 18, in Canarsie and Flatlands, the statement said. It added he was a teachers’ union representative.

Capuano was arrested the same day his home was searched. He admitted to investigators — and to the judge in his pre-sentencing statement — that he had used both his personal and union phone to download child pornography, the statement said.

He posted “child pornography images and videos” — with children as young as 3 to 5 years old — to a chat room in a publicly available internet application, the statement said.

advertisement | advertise on newsday

During the search, Capuano admitted to federal agents that he had an internet account “to trade child pornography,” adding “he had tried to stop but couldn’t a number of times,” according to the complaint filed by Assistant U.S. Attorney Allen Bode for the Eastern District.

In April, a Homeland Security Investigation into people who share child pornography led to the discovery of the images Capuano had posted, the statement said. His location was then traced through his account.

“We will relentlessly investigate and pursue cases of child predators who hide behind their computer screens and bringing them into the light,” said Angel M. Melendez, special agent-in-charge, U.S. Immigration and Customs Enforcement (ICE), Homeland Security Investigations (HSI), New York.

A spokesman for Rohde said he was not released on bail after his arrest.