(Reuters) - Comcast Corp, the owner of NBCUniversal, said on Thursday it would buy Hollywood studio DreamWorks Animation SKG Inc for $3.8 billion to boost its family-friendly offerings and help it take on media conglomerate Walt Disney. The acquisition will add major children’s franchises to Universal’s film library such as “Shrek,” “How to Train Your Dragon” and “Kung Fu Panda,” which it could tap for its growing theme parks and consumer products businesses.

Comcast’s Universal Pictures found success with blockbuster family films like “Despicable Me” and “Minions,” but this deal will ramp up its portfolio.

DreamWorks’ burgeoning TV business will also be a boon to Universal, Wall Street analysts said. DreamWorks provides original programming to streaming service Netflix and other digital platforms that are eager for content as TV viewership rapidly moves online.

“It’s a sensible strategy,” MoffettNathanson analyst Craig Moffett said. “They are buying characters.”

In addition to brands it created, like “Shrek,” DreamWorks owns rights to iconic characters such as Lassie and Casper the Friendly Ghost that it acquired in its 2012 purchase of Classic Media.

“There’s a lot of opportunity for them to create interesting content out of those brands and monetize them,” Moffett said.

Comcast, the largest cable distributor in the United States, has steadily boosted its ownership of content and invested in expanding its theme parks business, positioning itself as a diversified conglomerate to rival Disney.

Jeffrey Katzenberg, CEO of Dreamworks Animation, speaks at the 2014 Milken Institute Global Conference in Beverly Hills, California April 28, 2014. REUTERS/Lucy Nicholson

The $41-per-share cash offer represents a premium of about 27 percent to DreamWorks’ Wednesday close.

DreamWorks shares, which have gained nearly 50 percent in the last six months, soared 24 percent to $39.95 on Thursday.

Chief Executive Jeffrey Katzenberg will become chairman of DreamWorks New Media, which will include the company’s ownership interests in technology company NOVA and Awesomeness TV, a teen-focused studio that cultivates stars of Alphabet Inc’s YouTube and other digital platforms. Katzenberg will also serve as a consultant to NBCUniversal.

DreamWorks Animation was spun off from DreamWorks Studios in 2004. The studio was founded in 1994 by Katzenberg, Steven Spielberg and David Geffen.

The animation studio struggled in recent years as the market for children’s movies became crowded. In 2015, it cut one-fifth of its workforce and reduced its movie slate from three films a year to two. This year, it had a hit with “Kung Fu Panda 3.”

DreamWorks Animation had come close to being sold before.

In 2014, the company held talks about a possible sale to Japanese communications and media company Softbank Corp, a source with knowledge of the matter told Reuters at the time.

Later that year, toymaker Hasbro Inc held preliminary talks to buy DreamWorks Animation, according to another source at the time. The talks formally ended a few days later after Hasbro’s board voted to walk away.

Stifel analyst Benjamin Mogil said he did not think another bidder would come in and top Comcast’s offer “given the valuation and the operational role for DreamWorks Animation CEO Jeffrey Katzenberg in this deal.”

DreamWorks Animation was advised by boutique investment bank Centerview Partners Holdings LLC, which Reuters first reported on Wednesday, and legal adviser Cravath, Swaine & Moore LLP. Comcast’s legal adviser was Davis Polk & Wardwell LLP and the company did not list a financial adviser.