Rupert Everett stars as Oscar Wilde in “The Happy Prince,” a dramatic portrait of the Irish playwright in his final days, which Everett also wrote and directed. (Wilhelm Moser/Sony Pictures Classics)

Rupert Everett’s film “The Happy Prince” is an attempt at artistic reinvention — both of its subject, Oscar Wilde, and the man who plays him.

True, it’s a role that Everett seems to have spent his entire career preparing for. Although the film marks the 59-year-old actor’s debut as a writer and director, it is not the first time that Everett has portrayed the Irish playwright. In 2012, he appeared in a London revival of David Hare’s 1998 stage play “The Judas Kiss,” about Wilde’s decision to mount a doomed legal defense against accusations of being a “sodomite” because of his sexual relationship with a young aristocrat, Lord Alfred “Bosie” Douglas.

Everett has also has appeared in two film versions of Wilde’s plays: “An Ideal Husband” (1999) and “The Importance of Being Earnest” (2002). Even his breakout 1984 film role in “Another Country” feels like an early precursor of what was to come. That BAFTA-nominated performance, as a fictionalized version of the gay British spy Guy Burgess, was notable, according to the New York Times, for the character’s “Wildean poses of decadence.”

But his latest film, “The Happy Prince,” is actually a look at the final days of Wilde’s life, days spent in exile after imprisonment on charges of “gross indecency,” i.e., for homosexual acts. Everett describes it as less of a tragedy than a “shadowy romance,” a tale of a “star on the skids, living in 1890 Paris in a series of cheap hotels.” He wanted to correct what he calls “the Wilde of folklore”: the witty bon vivant and married family man portrayed on celluloid by such actors as Peter Finch, in the 1960 film “The Trials of Oscar Wilde,” and by Stephen Fry in 1997’s “Wilde.”

“The Happy Prince,” which takes its name from a children’s story written by Wilde about a bejeweled statue of a prince that falls into ruin and decay, focuses more on the devastating repercussions of what, according to Everett, were Wilde’s “gigantic, Earth-shattering errors of judgment”: to wit, getting involved with Bosie — handsome, spoiled and impossibly selfish — in the first place and then trying to defend his honor.

Colin Morgan, left, as Bosie and Everett as Wilde in “The Happy Prince.” (Wilhelm Moser/Sony Pictures Classics)

The film also attempts to set the romantic record straight: Bosie (played here by Colin Morgan) was not Wilde’s one great paramour, as he is often characterized. Rather, that honor falls to Wilde’s loyal friend, literary executor and presumed first lover, Robbie Ross (Edwin Thomas), who stays by Wilde’s side to offer comfort as he is dying.

For Everett, too, “The Happy Prince” is something of a resuscitation effort. Over a long career, the actor says in a recent visit to Washington, he has experienced multiple periods in which acting work — or the kind of acting work that he aspired to — had simply “evaporated.”

From the outside, you might not necessarily notice these droughts. Everett’s résumé includes steady voice work in such animated films as the Shrek franchise and appearances in such TV series as “The Name of the Rose,” along with regular film roles. But he also notes that, round about the time of his memorable 1997 appearance in “My Best Friend’s Wedding,” he realized that was stuck.

“By the end of the last century,” he says, “I had developed this career as a gay best friend, just by chance, really. I suddenly became extraordinarily successful being that. I got a lot of opportunities, but mostly those opportunities called for me to repeat the role.”

“After a bit, people get bored,” he added. “I get bored, too.”

Put another way, as Everett entered the new millennium, he had become “better known for being gay than for being an actor,” he says. Did he identify with Wilde’s banishment to the fringes of society? “When I was sitting, not working so much, yes,” says Everett. “I thought, ‘God, I feel kind of exiled, too, in a way.”

Enter Oscar.

The actor spent a couple of months, in his down time, writing the screenplay for “The Happy Prince,” a labor of love that would appease his fixation with Wilde, a character whose Christlike sense of martyrdom and deep humanity might just save his creative soul. The plan was that he would shop it around to directors and take on the meaty role himself, reinvigorating his flagging acting career. “It took me two and a half years to get seven no’s from seven directors,” he recalls. And he thought: “This script is going to be dead. I might as well try and direct it myself.’ ”

Everett, right, on the set of “The Happy Prince.” (Wilhelm Moser/Sony Pictures Classics)

Never having made a movie before, Everett had no idea just how complicated that process would be. Ten years went by, he says, just to get to preproduction.

Now that it’s in theaters, Everett couldn’t be prouder. He views the film, on the one hand, as a historical document, a reminder of a time that, for him, feels all too recent — and personal. “I remember coming to London in 1975, when it had only been legal to be gay for seven years,” he says. “The law was fairly ambiguous as well, having to do with ‘public’ displays of homosexuality versus ‘private’ homosexuality, which was all that had been legalized. When the police got bored, they’d raid gay clubs and herd everyone into paddy wagons.”

At the same time, Everett says, “The Happy Prince” is a story “for today,” one that has as much to say about “Trump’s America” as it does about Wilde’s 19th-century Europe.

The gay community, he says, has “the force of history behind us, moving us forward.” At the same time, he laments the rising tide of populism and bigotry. “We, as a minority, must be vigilant about that.”

Everett points out that, in early October, the State Department announced that it would refuse to issue visas to same-sex partners of diplomats entering the country, unless they are legally married — even though same-sex marriage is legal in only 25 countries.

“Being an artist,” he says, “one is also, always, an activist. So do I feel like I have now become one? I don’t know. After years and years of working as an actor, what I feel like, finally, is an artist.”

The Happy Prince (R, 104 minutes). Opens Friday at area theaters.