Harry Potter author JK Rowling has unveiled a magical three-dimensional image of herself at London's National Portrait Gallery.

The full-length work shows the writer sitting at a table with a notepad and a plate of boiled eggs, evoking the cafe where she wrote much of her first best-seller on the boy wizard.

Rowling, who rarely appears in public, posed twice for artist Stuart Pearson Wright at her mansion in Perthshire, Scotland.

She has said Harry Potter's character came to her "fully formed" during a train journey from Manchester to London. She completed much of the first novel, Harry Potter and the Philosopher's Stone, in longhand in a cafe while living as a single mother in Edinburgh. Sometimes she still writes there.

Six of the seven books in the series have been published - one for each year Harry and his friends spend at the Hogwarts school for wizards. The novels have been translated into 62 languages, selling more than a quarter of a billion copies world-wide.

Yet Wright's portrait, begun in early 2004, refers to Rowling not only as a writer, but also as a mother. The three eggs symbolise her three children.

Wright, 30, a London-based artist who won the BP Portrait Award in 2001, said he drew inspiration from 18th century toy theatres.

"It felt like being a kind of director bringing together a set design, actors and props and then lighting the whole thing."

He depicted the writer, barefoot and wearing a white dress, in a distorted three-dimensional space. The room is empty, except for an aloe vera plant, a radiator and a light switch.

Each object was placed at a different angle for viewers to see it as either two or three-dimensional, depending on where they stand.

The illusionary effect suggests the fantasy world Rowling created in her books.

"This is a captivating portrait with more than a touch of magic," said gallery director Sandy Nairne.

The painting, unveiled on Tuesday, is open to the public to view for free as part of the permanent collection.