A demoted Queens ex-principal took a six-month medical leave on the eve of a termination trial that was to display dozens of pornographic photos allegedly found on her city-issued laptops.

Annie Seifullah was removed as principal of Robert F. Wagner Jr. Secondary School for Arts and Technology in May 2014. She took the leave for post-traumatic stress, her lawyer said, which she suffered in November 2015 when male students in Automotive HS learned about the scandal and harassed her.

The furlough forced a last-minute cancellation of her long-delayed disciplinary hearing. The charges against her include keeping the sexually explicit images on Department of Education laptops and sexting on city time with two other DOE administrators.

The case also pits Seifullah against a school parent with whom she had a tempestuous affair.

A week after her Feb. 13 hearing was canceled, Seifullah filed a notice of claim against the city, the DOE and Chancellor Carmen Fariña. It accuses officials of threatening to air photos — including some of her engaged in sex acts — if she didn’t resign.

Seifullah in her claim contends her ex-boyfriend and then-Parent Association president, Robert V. Sofia, removed photos from her personal laptop and planted them on several DOE computers as part of an “extortion plot” for money.

When she refused his financial demands, she alleges, Sofia turned the computers over to school investigators. Sofia gave several photos to The Post, which ran a story after the DOE removed Seifullah from the Long Island City middle-high school.

Seifullah’ s lawyer, Peter Gleason accuses DOE of “double reverse extortion.”

“The DOE has brought slut-shaming to a new low,” he wrote.

Sofia, who was set to testify on the first day of the hearing, denies planting the photos.

He said in a statement Saturday that he never knew Seifullah to own a personal computer and that she gave him access to four DOE laptops, which she used to store images of herself in sexual acts.

Echoing statements he made to probers, Sofia called her “a sexual predator” who “used money, sex and her positions” to “manipulate men and women — including me.

“As then-PA president and member of the (School Leadership Team), I had to summon the strength to report what Seifullah was doing to the NYC DOE and do not regret it,” he added.

Seifullah was demoted to teacher. Her tenure requires a hearing by an arbitrator before she can be fired. Her annual salary is $72,167.

The DOE had no comment on Seifullah’s case, with a spokesman saying only, “She applied for a leave in accordance with DOE protocol.