BOSTON – Governor Deval Patrick on Friday signed a bill passed by the Legislature to close a loophole in state law that the Supreme Judicial Court said made it legal to take cellphone pictures up a woman’s skirt.

“I’m hard-pressed to think that a person doesn’t have a reasonable expectation of privacy in their own clothes,” Sen. Brian Joyce, D-Milton, said after the Senate unanimously passed an amendment sent over from the House that now makes it illegal for someone to photograph the “sexual or other intimate parts” of an unsuspecting person.

“It’s sad and somewhat bizarre that we even have to pass such a law,” Joyce said. “Clearly there are some twisted individuals.”

The state’s high court ruled on Wednesday that the Massachusetts law against secretly photographing or videotaping a person who is “nude or partially nude” did not apply to so-called “upskirting,” in which someone uses a cellphone to take a picture up the dress of a woman.

The ruling came in an appeal by Michael Robertson, who was accused of taking photographs and video of women on the MBTA in August 2011 by aiming his cellphone up the skirts of the women seated across from him.

Joyce said that within minutes of the ruling he began receiving complaints from constituents asking for a change in the law.

Legislators in the House contacted the court to ensure that the bill addresses the loophole cited by the justices.

“We used language that would appropriately correct any loopholes,” Rep. James Cantwell, D-Marshfield, said.

In the new text, those “upskirting” could face up to 21/2 years in a state correction facility.

Cantwell praised the House for acting quickly to address the issue he said was the result of “new technology.”

Sen. John Keenan, D-Quincy, said the original law was written before phone cameras became common. He said that the Senate took time from its debate of an $18.1 billion transportation bond bill on Thursday to pass the law rather than wait for another formal session.

“The people that have the legal expertise immediately went to work,” Keenan said.

He expects the language of the bill will prevent future appeals such as Robertson’s.

“It looks like it was drafted well enough to withstand challenge, and to allow police and prosecutors to bring charges against individuals engaged in the conduct that this man was engaged in,” Keenan said.

The legislative action was greeted with relief by T riders such as Emily McKnight, 21, who said she will ride the Red Line from college in Boston to her family in Milton on Saturday.

Page 2 of 2 - McKnight said she had no idea that upskirting was a problem until the court ruling.

“I’m more aware now, but I don’t think a law is going to stop anybody,” McKnight said. “I guess I’ll just keep my legs crossed.”