Photo: Susie Kelly Photo: Susie Kelly / Special To The Chronicle

A humpback whale has been leaping out of the water, waving its flukes and putting on a show for boaters, sightseers and photographers in San Francisco Bay. But for all the endearing entertainment, local experts are worried about a skin condition and a troubling dearth of blubber.

The giant cetacean’s antics the past couple of weeks come at the tail end of a troubling gray whale migration that saw more than a dozen die, many from apparent starvation and some inside the bay. But humpbacks are a very different animal and, unlike their gray brethren, are regular visitors to the bay in the summer months.

A local photographer captured a spectacular image last week of the humpback breaching with San Francisco’s tallest building — Salesforce Tower — and the Bay Bridge in the background.

The image, taken by Susie Kelly, showed the same female whale researchers observed for 19 straight days in an Alameda lagoon until it pulled up stakes on Friday. The humpback was nicknamed Allie by locals, who kept tabs on her from the USS Hornet Sea, Air and Space Museum.

“This one was in poor health and came into a very protected area of water in the bay,” said Bill Keener, an associate with the new cetacean field research program at the Marine Mammal Center in the Marin Headlands. “Whether it came in to feed or to rest, we don’t know. Its skin condition was rough and degraded, indicating it was in poor health.”

The shallow lagoon does not have a lot of food that a humpback can eat, and the whale watchers in Alameda were so worried that they held a “prayer circle” for her.

“I wish she was out in the ocean, but I was thrilled I was able to catch her,” said Kelly, an amateur photographer from San Rafael who watched as the whale approached within 12 feet of where the World War II aircraft carrier Hornet is docked. “I hope she’s well and back out under the Golden Gate.”

Humpbacks have long pectoral fins and distinctive knobby heads and can grow to 52 feet long and weigh almost 80,000 pounds. The species, known for its acrobatic breaching, makes its north-south migration about this time every year, but unlike grays, which make a beeline to the arctic, a lot of them feed along the coast off San Francisco.

Humpbacks were first seen entering San Francisco Bay in significant numbers during the spring and summer of 2016. Since then, Keener said, 70 humpbacks have been identified feeding in the bay and many more congregate between April and November outside the Golden Gate, in Monterey and Bodega bays and around the Farallon Islands. This is the first one he has seen that isn’t healthy.

“They’ve been coming in every year — this is the fourth summer in a row. So this is their feeding area,” he said. “We don’t know if this animal is just old, but there are no entanglements or significant injuries. Hopefully it needed some time to rest and recuperate and now it has moved off.”

The concerns are understandable, given that emaciated gray whales have been washing up in disturbing numbers along the coast this year. Many grays have come into the San Francisco Bay — highly unusual behavior for the species — in an effort to find food.

John Calambokidis, a senior research biologist for the nonprofit Cascadia Research Collective, said grays have been dying all along the West Coast — 29 have washed up in Washington State. It is happening because there is too little food in the Arctic to sustain them on their annual 11,000-mile migration from Alaska to Mexico and back again, he said.

But the humpback situation is entirely different, Calambokidis said.

Gray whales feed by scooping up mud and siphoning out tiny arthropods found mostly in shallow Arctic waters. Humpbacks, on the other hand, can go into deep water to eat krill and come into shallow water to consume small fish like anchovies, both found in abundance along the coast of San Francisco and Monterey Bay.

The surge in whale sightings over the past few years is largely because the leviathans have made a remarkable recovery from near-extinction — 90 percent of them were killed by commercial whalers in the 19th and early 20th centuries.

Calambokidis said both humpback and gray whales in the Eastern North Pacific have recovered, with about 20,000 humpbacks and 27,000 gray whales now inhabiting the region. The numbers are close to their historic populations.

He also said humpback numbers have increased by 7% to 8% every year since he began studying them in the 1980s. At least 40,000 of the creatures now live in the world’s oceans.

“As the humpback whale population has increased, we’ve seen more and more whales showing up in new areas where we haven’t seen them,” including San Francisco Bay and Puget Sound, said Calambokidis, who estimated that 3,000 humpbacks now feed along the West Coast compared to less than 1,000 in the 1980s.

“What I can’t tell you is historically how many humpbacks used to use San Francisco Bay,” he said. “All I can say is it fits the pattern of increased numbers.”

Keener and Calambokidis agree that one sick whale isn’t worth getting too alarmed about. The real danger that Allie and her cetacean comrades face is fishing gear and steaming ships.

Humpbacks often get tangled in fishing gear, most commonly crab pot lines. Collisions with ships have also become a major cause of death outside of the Golden Gate, where some 9,000 large vessels pass every year. An estimated 22 humpbacks are killed by ships off the coasts of California, Oregon and Washington each year, according to recent studies.

Jennifer Roco, who is blind, came to Alameda Point with her father Monday, hoping for a chance to hear the whale doing pirouettes and splashing down like she has been doing for two weeks.

“Even if I can’t see it, I still want to have a description from my dad and hear the whale splashing,” said Roco, 42, who was hoping maybe she could detect whale echolocation. “Maybe I can hear those sounds, too.”

After finding out that the whale had gone, she and her father, Ricardo, stood at the water with giant naval ships on their left and San Francisco’s downtown skyline straight ahead, contemplating life as a whale.

“It’s good news,” Ricardo Roco said, “because if it stayed here it would die.”

Biologists at the Marine Mammal Center are asking boaters and kayakers to keep a lookout for Allie, but to maintain a safe distance and report her location if they see her.

Ashley McBride and Peter Fimrite are San Francisco Chronicle staff writers. Email: ashley.mcbride@sfchronicle.com, pfimrite@sfchronicle.com. Twitter: @Ashleynmcb, @pfimrite.