In France, at least, Gainsbourg’s legend has hardly waned in the decades since his death. It is therefore not surprising that he has been admitted to the pantheon of film biography, joining Édith Piaf, so memorably impersonated by Marion Cotillard in the 2007 film “La Vie en Rose,” as well as English-language stars like Ray Charles and Johnny Cash. Directed by Joann Sfar, a comic-book artist making his feature debut, “Gainsbourg: A Heroic Life” is a primer for the curious and a keepsake for fans, an affectionate tribute that follows its hero through the familiar stages of modern celebrity, from childhood trauma to picturesque dissolution.

Born Lucien Ginsburg in Paris to a Jewish family from Russia, this future pop idol (played as a boy by Kacey Mottet-Klein) survives the Nazi occupation with a mischievous resilience that sets a tone for his later escapades. He also acquires an alter ego — his true “face” and secret sharer — who is incarnated by a giant, hook-nosed puppet, one of two fantastical effigies, drawn from the imagery of anti-Semitism by way of Mr. Sfar’s prodigious visual imagination, that join the celebrity impersonators who populate the film.

Of these, the hardest-working is Eric Elmosnino, who plays the adult Gainsbourg with jug ears, heavy eyes, a gravel voice and a perpetual Gitane. Gainsbourg turns, before our eyes, from a skinny young nightclub performer in a trim tuxedo into a shaggy and grizzled talk-show fixture, all the while walking the narrow boundary between repulsiveness and charm.

Along the way there are marriages, love affairs and a handful of songs, among them famous duets sung with Brigitte Bardot (Laetitia Casta), France Gall (Sara Forestier) and Jane Birkin (Lucy Gordon). Mr. Sfar and his production designers recreate the look and mood of the times, and they provide a generous tour of Gainsbourg’s musical styles, which encompassed music hall crooning, teeny-bopper bubblegum, rock, folk and reggae. You can hear snippets of most of his greatest hits, including “Bonnie and Clyde,” “Comic Strip” and of course “Je T’Aime ... Moi Non Plus.”