NYPD Commissioner Bill Bratton on Monday urged New Yorkers to harden their hearts and close their wallets if they want to help stem the city’s vagrancy crisis.

The top cop said handing over cash to panhandlers only encourages them to beg on the streets, and he recommended walking by without sparing any change.

“My best advice to the citizens of New York City: If this is so upsetting to you, don’t give. One of the quickest ways to get rid of them is not to give to them,” Bratton said.

“New Yorkers who are complaining so much about it, well, one of the things they can do is stop contributing to it.”

Bratton made the remarks at a news conference with Mayor Bill de Blasio outside City Hall after they were shown a photo of a supposedly homeless person with a menagerie of pets panhandling at Broadway and West 68th Street on Saturday night.

The commissioner said bums use pets to lure in people.

“You can see that repeated in a number of locations around the city, with the animals, et cetera, which is, for the beggars, that’s an additional inducement to people to give,” the commissioner said.

Bratton — who has blasted New York’s courts for making it tough to clear vagrants off the streets — noted the photo illustrated something that “would be possible for our officers to actually act upon.”

“That individual is not sitting there by himself. He’s taking up significant public sidewalk space,” Bratton said.

“So if somebody were to have called and complained about him, our officers could have removed him.”

He also said the NYPD was working with its precinct commanders to teach cops about “the nuances of the laws that the officers have to work with to enforce — and they are nuances, very fine nuances.”

“But in terms of the picture you just showed me, that would be somebody clearly who would have no right to be basically occupying that sidewalk space,” he added.

De Blasio wouldn’t comment directly on the photo — or echo Bratton’s advice — but said homeless people living on the Big Apple’s streets was “upsetting every time” and “not something that any community should have to live through.”

The mayor — who tucked away the photo in his jacket without displaying it — also touted how his administration had broken up “21 full-blown encampments where people were living for years, doing drugs, sleeping overnight.”

“It was absolutely unacceptable — not anything that should’ve been tolerated in modern civilization. Those were taken down,” de Blasio said.

“Any time we see a report of something like this, NYPD and Homeless Services move in, and both [work] to restore the quality of life for everyone who lives in the area, but also to get services to the people involved.

“There was a report the other day in Soho. That was resolved within 24 hours,’’ he added.

Hizzoner also said he was “proud of the fact that we got 38,000 people out of shelter and into housing.”

But, he added, “we’ve got a lot more to do.”

“The bottom line is if we see a situation like this, it will be dealt with,” the mayor said.