Emma Watson works her magic in “The Perks of Being a Wallflower” after a decade of Harry Potter-film fame. Photo: Everett Collection

While countless novelists have written screenplays, it’s extremely rare for one to also direct a film version of his own work — the only two I can think of off the top of my head are Norman Mailer (“Tough Guys Don’t Dance’’) and Stephen King (um, “Maximum Overdrive’’).

Stephen Chbosky — whose credits include the screenplay for Chris Columbus’ not-great movie of “Rent’’ as well as some TV — has crafted a surprisingly pungent and cinematic version of his autobiographical, coming-of-age best seller “The Perks of Being a Wallflower.’’

This would be tricky material to handle even for a director with more objective distance from the material.

Set in 1991 Pittsburgh — which often seems like a decade earlier based on the clothes and hairstyles — the film focuses on Charlie (Logan Lerman of “Percy Jackson & the Olympians: The Lightning Thief’’), a clinically depressed 15-year-old.

Struggling with his freshman year after a hospitalization following the suicide of his only friend, Charlie receives encouragement in his aspirations as a writer from a high school teacher (Paul Rudd, playing it mostly straight) who turns him on to Salinger, Kerouac and Fitzgerald.

Our socially maladroit hero is taken under the wing of a beautiful senior Sam (Emma Watson, playing a not-quite-manic pixie dream girl, complete with a Carey Mulligan-esque bob, in her first major role after a decade of Hermione Granger).

Sam’s efforts to make Charlie hipper and looser are abetted by Sam’s flamboyantly gay half-brother, Patrick (Ezra Miller, who played the extremely bad seed of “We Need To Talk About Kevin’’).

Soon our hero is awash in a world of high school sex, drugs and rock ’n’ roll, and it would have been very easy to turn “The Perks of Being a Wallflower’’ into a cliché-fest; “The Rocky Horror Picture Show’’ even figures very prominently in the plot as a device for Charlie’s liberation.

Charlie falls for Sam (who already has a jerk boyfriend) and her brother Patrick crushes hard on Charlie, who rescues Patrick from a beating at the hands of his closeted boyfriend.

“The Perks of Being a Wallflower’’ is the sort of lower- budget personal film you hardly see being released by a major distributor anymore, except during awards season.

Under Chbosky’s sensitive direction, practically every scene, many of them painful, rings honest and true — especially those involving Charlie’s well-meaning parents, played by Dylan McDermott and Kate Walsh (Joan Cusack turns up as a sympathetic psychiatrist).

The acting is first-rate, and remarkably there’s no sense that the sometimes tough material (which barely skirts an R rating) has been watered down to make it more palatable for a wider audience. I just wish Chbosky had changed that terrible title for the movie.