– The Triumph of David was a mess.

Original paint on the 17th-century canvas was faded and flaking. Newer paint from inexpert restoration attempts had become discolored.

Standing before the painting at Villanova University, conservator Kristin deGhetaldi could tell this with her experienced eye. But to revive the painting, how could she tell where old paint ended and new paint began? The answer: a mix of art and science.

The 12-by-19-foot painting, thought to be the work of Italian artist Pietro da Cortona, is in the midst of a two-year, $100,000 conservation effort.

Researchers have used advanced scanning techniques to determine the chemical composition of various layers of pigment to help deGhetaldi and her team decide which layers to remove.

In September, officials brought in technicians to X-ray the painting and were surprised to find a mystery figure beneath the surface.

It began in 2006 with chemistry professor Anthony Lagalante, who teaches a course on the chemistry of painting. He was looking for artwork on campus that his students could see in person.

The Rev. Richard Cannuli, curator of the school collection, told him about the painting attributed to Cortona — an architect and artist best known for his ceiling fresco in the Barberini Palace in Rome.

Largely forgotten, the Cortona hung in an old wing of Villanova’s Falvey Memorial Library that was used to store boxes of microfiche.

Lagalante was stunned. “You look up on the wall, and there’s this giant painting that is clearly suffering,” he said.

He learned it had been given to the university in 1950 by the American wife of an Italian nobleman. Art historian Tim McCall agreed that the scene of David after he killed Goliath was worth saving.

The university hired deGhetaldi and she and a team of interns started work in 2013.

Team members used a handheld device that measures how different regions fluoresced in response to X-rays — a technique that gives a snapshot of the elements in the paint.

The conservation team removed tiny flecks of paint that were studied with an electron microscope that revealed each layer’s composition.

In September, X-rays showed that beneath a soldier’s shield was the hidden image of a man holding a symbol of power in ancient Rome.

The paint used in the shield is from the 17th century, so the man was covered up soon after the painting was completed.

Did the artist change his mind about the composition? Did a wealthy patron want the figure blacked out?

That and other mysteries remain. McCall, Lagalante, and deGhetaldi will go to Rome in March to meet with experts who may be able to help.