James Meyer outside court Wednesday, where he pleaded to stealing the work of former boss Jasper Johns (inset).Gregory P. Mango

Famed artist Jasper Johns’ former trusted longtime assistant copped a plea Wednesday to swiping 22 works from his boss and then peddling them through an unsuspecting Manhattan art gallery for $6.5 million.

President Obama presents Jasper Johns with the 2010 Medal of Freedom.Getty Images

He had faced up to 30 years behind bars before his plea deal with the feds.

As part of his deal, he also agreed through his deal with the feds to forfeit $3,992, 500 in illegal profits he made off the scheme.

Meyer began working for Johns in 1985 — then turned bad eight years ago, stealing art from his boss and altering paperwork to make it look like they were gifts to him, prosecutors said.

Meyers admitted swiping the paintings from 2006 to 2011 from a file draw at Johns’ art studio in Sharon, Conn., and taking them to an unidentified Manhattan art gallery to sell without Johns’ knowledge.

Johns, 84, had yet to complete the pieces, but Meyer told the gallery owner they were finished works, the indictment says.

He even allegedly created fictitious inventory numbers to give the impression that they were finished works.

Johns became famous for iconic works like “Flag.”AP

“Did you know what you were doing was wrong?” Judge Paul Oetken asked.

“Yes,” Meyers said.

“When you crossed state lines, were you intending to the sell the artwork?” the judge asked.

“Yes,” Meyer said.

The gallery isn’t identified in the indictment. It sold the works for $6.5 million, with Meyer getting more than half of the proceeds off the sales.

Meyer, when arrested in August 2013, was also slapped with wire fraud charges.