There has been a social media outcry after inch-long spikes were installed in paving in London apartment block, apparently to ward off homeless people.

Images of the metal studs were uploaded to Twitter at the weekend and soon went viral, with London mayor Boris Johnson labelling the spikes "ugly, self defeating & stupid".

Local resident Andrew Horton, 33, who took pictures of the studs outside the Southwark Bridge Road apartment block, told the London Telegraph: "It certainly looks like they were placed there to deter homeless people. It's dreadful."

Images of the metal studs soon went viral. Photo: Twitter

The studs, similar to those used to keep pigeons off buildings, have been installed in the alcove of the apartment block, which is opposite a hostel for homeless people with mental health problems.

The petition condemns the spikes as an inhumane way of "managing" homelessness.

"We should be offering practical and emotional support to help the most vulnerable to get back on their feet," Ms Wells said.

"[We should not] be sending them the message that they are pests that need to be warded off."

So far, the petition has garnered more than 19,400 supporters.

A spokeswoman for Southwark Council told the Guardian there was little the council could do unless the studs were in breach of planning regulations.

Meanwhile, some US cities are banning people from giving food to the homeless in public.

A US National Coalition for the Homeless report, released to VICE News, highlights the types of bans and restrictions American cities use to shut down religious and community groups that give out food.

In 2012, Houston in Texas passed a law to fine anyone who gave food to more than five people in public without written permission from a local council.

The Council to Homeless Persons in Melbourne says such treatment only makes matters worse for some of society's most vulnerable.

"Rather than resorting to this cruel approach they should be asking why people are sleeping on the street," the council's policy and communications manager, Lanie Harris, said.

"Tackling rough sleeping is not about moving people on from one area to another. It's about getting them into a safe, warm home and providing the support so that they stay there."

Bruce Redman, from the Salvation Army, said the very thought of society treating people as "vermin, pests or animals" was disturbing.

"This just tears at my heart," he said.

"These are people, and they are people with a story and their own concerns. It's not like many people choose to be homeless."

Dr Redman said strategies such as paving spikes were unlikely to be implemented in Melbourne, because "Melburnians are much more tolerant and generally care for the less fortune, and in particular, the homeless".

"I've seen some amazing kindness here for people who are doing it tough ... and I find it so hard to come to terms with the situation in London and the attitudes of our American friends," he said.