Over the course of more than a century of research and development, Eastman Kodak Co. has built up a library at its Rochester headquarters of close to 500,000 organic compounds. Last week the special collection, which experts say is one of the largest in the world, helped drive the photography giant's decision to spend $5.1 billion to buy Sterling Drug Inc. of New York.

Kodak officials have long believed that the chemicals they developed for photographic and specialty fields also have commercial potential as pharmaceuticals. Three years ago, they began testing that theory in earnest, combing through their library and conducting sophisticated tests on the most promising of their compounds.

Kodak won't say how successful the screening has been, but apparently the company felt confident enough to jump head-first into the highly competitive pharmaceutical market by paying what some analysts consider a steep price for Sterling Drug.

"The theory is that Sterling provides Kodak with downstream capabilities in marketing infrastructure, the regulatory process ... critical parts of the process that Kodak needs to become a major player," said Peter Enderlin, an analyst with Smith Barney Harris Upham.

Sterling gives the company the "critical mass" to compete successfully in the drug business, said Charles Smith, spokesman for Kodak's pharmaceuticals division.

Kodak isn't the first company with a background in chemical engineering to branch into drugs.

Bayer AG, the German chemical giant, gave the world aspirin. Pfizer Inc. and Merck & Co., two of the largest drug companies in the United States, started out in the chemical business. Over the past few years, as overseas competition reduced profits in the commodity chemicals business, the three largest U.S. chemical manufacturers -- du Pont, Dow Chemical Co. and Monsanto Corp. -- have made significant investments in the highly profitable and rapidly growing $110 billion dollar health products field.

Like Kodak, traditional chemical companies have seen a fundamental synergy between their own businesses and the pharmaceutical industry. Du Pont entered the drug business in the late 1960s, for example, when it discovered almost by accident that a compound developed as an agricultural chemical was highly effective against certain types of the influenza virus. Today, the vaccine, Symmetrel, is also used in the treatment of Parkinson's disease.

Monsanto Chief Executive Richard J. Mahoney called his company's $2.75 billion acquisition of G.D. Searle in 1985 a "natural progression." Since then, Monsanto has invested hundreds of millions of dollars in R&D in the drug field. Mahoney characterized the two industries as similar, with both requiring expertise in synthesizing large numbers of compounds and a long term commitment to research.

But while drug and chemical research are compatible, industry experts say that marketing demands are not.

"Success in the drug industry is as much marketing and distribution as it is having the product. Without the right distribution channels you can't do anything," said James Wilbur, an analyst with Smith Barney.

Chemical companies interested in buying into the pharmaceutical business have looked for strong sales networks and experienced management. Monsanto bought Searle, for instance, despite what industry sources called its aging product line and a second-class research effort. Sterling has many of the same limitations as Searle, with few of its own prescription products, but Kodak saw in the company a much needed pipeline to pharmacy shelves.

So far, the success of diversification into pharmaceuticals has been mixed. Dow Chemical bought the Merrell half of Richardson-Merrell in 1981 for $260 million, and passed the $1 billion mark in revenue for its pharmaceutical division almost immediately. Monsanto, on the other hand, has already lost close to $300 million on Searle and doesn't look to break even until 1990 at the earliest.

Analysts generally endorse the spirit of the Sterling acquisition, but say that the company may have paid too high a price. The deal will push Kodak's debt load to a worrisome 55 percent and will dilute earnings for the next four years.

"They had the attitude that if they didn't do it now, there would be nothing left, and that {fear} forced them into buying something bigger than they wanted," said Jonathan Gelles, an analyst with Wertheim & Co. in New York

Another question is whether Kodak's chemical library will live up to expectations. "Maybe they're onto something. Maybe they have something there. But it's a long shot," said an official with Nova Pharmaceutical Co., the Baltimore firm that is assisting Kodak with the screening.

At a time when some companies in the pharmaceutical field are moving into rational design of drugs -- identifying human medical needs and designing drugs to meet them -- Kodak is gambling in no small part on the traditional method of random screening of chemical compounds. "The industry is getting a little more difficult these days," said Gelles. "The easy things have all been done."