In 1860, an English bookseller named Eadweard Muybridge smacked his head during a runaway stagecoach accident and became a little bit unhinged. The injury permanently altered Muybridge’s mind—he hit his head so hard that he temporarily lost his sense of taste. But it also unleashed a wave of obsessive creativity that indirectly led to the invention of the animated GIF.

On a doctor’s recommendation, the bookseller took up photography and became so prolific that he eventually dropped his old job and became a professional photographer. Later that decade, he went to the United States and made a name for himself photographing Yosemite Valley and other wonders of the American West.

In the early 1870s, Muybridge's talents attracted the attention of railroad tycoon and former California governor Leland Stanford, who, according to an unsubstantiated legend, wanted to settle a $25,000 wager: Do all four hooves of a galloping horse leave the ground? (The truth is that Stanford was probably just curious for unscientific reasons: He wanted to learn how to make his pricey racehorses run faster.) To find the answer, the ex-governor hired Muybridge, who would spend the next six years tinkering with his cameras to capture the images.

It was an incredibly difficult project. In the early 1870s, the average camera’s exposure time elapsed for two seconds; capturing the split-second movements of a galloping horse was literally impossible. To solve the problem, Muybridge created “mechanical shutters, made of wood, rubber springs, and a trigger that would snap closed within one-thousandth of a second,” Haleema Shah writes in Smithsonian. The first images, however, were too blurry.

It didn’t help that Muybridge was running into trouble with the law. In 1874, his project stalled completely while he stood trial for murdering his wife’s lover. He was acquitted with help from Stanford’s lawyers, who argued it was a "justifiable homicide." (The composer Philip Glass would dramatize the trial in a 1982 opera called The Photographer.) Finally, in 1878, Muybridge successfully captured a running horse’s gait with the help of a few dozen plate-glass cameras. The verdict? Horses briefly go airborne.

For scientists, artists, inventors, and photographers, the pictures were groundbreaking—and today they’re iconic. “Many people didn’t believe it,” art curator Philip Brookman tells NPR. “They thought they were fake because the horse looked so strange.”

Muybridge later used the images to develop the world’s first motion picture projector, a revolving glass disc called the zoopraxiscope (or “animal action view.”) He would also take dozens more split-second action photographs—bison running, horses jumping hurdles, and even naked boys playing leapfrog. Today, these images are considered a distant ancestor of everything from the modern animated GIF to big-screen movies.

In fact, Muybridge showed the device to Thomas Edison in 1888, who eventually used the concept to develop the first motion picture exhibition device, the kinetoscope. So the next time you're giggling at the latest meme or watching the latest big feature film, remember you have a crafty (and murderous!) Englishman—and horses everywhere—to thank.