Instead, Maas sentenced Fairey, 42, to two years’ probation, 300 hours of community service and a $25,000 fine.

Maas cited Fairey’s history of “extensive charitable works” and his ongoing battle against Type 1 diabetes, which Fairey’s lawyer said had forced him to undergo two eye surgeries — and which couldn’t be properly treated in the slammer.

Earlier, Fairey offered apologies to The Associated Press — whose photo he ripped off — along with the court, his family and friends and “anyone else I might have harmed.”

He said that “violating the court’s trust” during his legal fight with The AP — which he settled for $1.6 million — “was the worst thing I’ve ever done in my life.”

“I’m deeply ashamed and remorseful that I didn’t live up to my own standards of honesty and integrity,” he added.

Fairey, of Los Angeles, had faced up to six months behind bars after pleading guilty to criminal contempt.

Prosecutor Dan Levy said Fairey deserved at least some time in prison or a halfway house and that letting him skate for his “extraordinarily serious litigation misconduct” would send “a terrible message to the world.”

“It says that if you’re an otherwise good person, you can engage in this kind of conduct without having your liberty taken away,” Levy noted.

In a statement, AP president and CEO Gary Pruitt said, “After spending a great amount of time, energy and legal effort, all of us at The Associated Press are glad this matter is finally behind us.”“We hope this case will serve as a clear reminder to all of the importance of fair compensation for those who gather and produce original news content.”