It could’ve been a tragic carpet ride.

When the first clip of Disney’s live-action “Aladdin” dropped in February, audiences were faced with their worst nightmare: a ridiculous, indigo-painted Will Smith. Viewers were understandably appalled that their beloved genie had gone from Robin Williams’ swift-talking clown to the love child of the Fresh Prince of Bel-Air and Violet Beauregarde. Disney, we thought, totally blue it.

Well, the studio must’ve rubbed the heck out of its magic lamp, because the family film has unexpectedly turned out shining, shimmering, splendid. Smith, who wisely steers clear of being a Robin Williams clone, makes for a jovial emcee. Even Guy “Swept Away” Ritchie does some uncharacteristically solid work.

Unlike Tim Burton did with the recent “Dumbo,” director Ritchie is not out to reinvent “Aladdin” and traumatize millions of millennials. He’s barely out to tweak it, beyond making sensible alterations for flesh-and-blood humans and 2019 sensibilities. Gilbert Gottfried’s harsh voice, for instance, would not feel right coming from the beak of a real parrot. And Agrabah can’t be as stereotypical as it was pre-Twitter.

But there are no major story deviations from the 1992 cartoon. Aladdin (Mena Massoud) is still a handsome pickpocket who hops around the market in the fictional Middle Eastern city making a dishonest living. One day, Princess Jasmine (Naomi Scott) wanders down from the palace in disguise, wanting to live like common people, and winds up meeting our man Al.

He’s smitten, but also knows that a small-time thief can’t wed royalty, no matter how lustrous his hair is. Good thing for Aladdin, then, that when he’s sent by the evil Jafar (Marwan Kenzari) to the Cave of Wonders to fetch a magic lamp, he rubs it and meets the genie. The magical being grants him three wishes. The big one? He wishes to become a prince. That way he can impress Jasmine and win her heart.

Shouldn’t be too hard. Massoud is quite a dish, with a boombox-over-head sensitivity and a good-enough voice. (The songs of “Aladdin” are iconic and undeniably melodic, but don’t require a Pavarotti.)

The one big-ish changeup here is the lovely Jasmine, who is made a bit less of a passive, tiger-owning pretty face. Now with more agency, she gets a brand new song called “Speechless” in which she wails her desire to be taken seriously in a dude-run society. Her dreams are made all the more forceful by Scott’s striking resemblance to Sarah Michelle Gellar of “Buffy the Vampire Slayer.” Jasmine’s out to slay, too … symbolically. Massoud and Scott make a live-action “Aladdin” succeed on a different level than a cartoon can — as a teary romance. “A Whole New World” is more moving than the original.

Smith, though droll, is not the bravura talent Williams was, and “Aladdin” is less funny for it. But his “Friend Like Me” and “Prince Ali,” which have a bit of added rap, are flashy and fab. And the “Independence Day” star will likely make a killing this Memorial Day weekend.