Carmelo Anthony’s revival almost didn’t happen.

The former Knick was getting ready to retire before the Trail Blazers finally signed him in November and got him on the court for the first time in over a year.

“I was preparin’ myself,” Anthony told ESPN’s Rachel Nichols. “And I had prepared myself to kinda just walk away from the game — if the right situation didn’t come about.”

“I say that because I know what I can do. So if I were just to go to a team and to a situation just to be on the team and it didn’t work out, it was gonna come back on me anyway. Like, the blame is gonna be on me anyway. So a situation like Portland, where I could just come in and just play my game and have a group of guys that really want me, and the organization that want me.

“There’s no better feelin’ than when you feel wanted. And I think that’s what kinda keeps me motivated and understandin’, like, this situation is — it is and was the best situation for me.”

So far, the match has been a strong one. The 35-year-old Anthony knocked off some early rust and through his first six games has averaged 17.7 points (on 46.2 percent shooting and 37 percent from 3) and six rebounds.

The Trail Blazers, who had their depth challenged by injuries, have won three straight with Anthony playing big roles in each of them.

Last season, Anthony lasted just 10 games with the Rockets before falling out of favor and being held out through a long string of inactives. They finally traded him to the Bulls in January before he was waived on Feb. 1 and remained unsigned until November.

Anthony reportedly joined the Nets and Knicks for pickup games and informal workouts over the summer, but neither served as a landing spot despite one being his hometown team (the Nets) and the other being his team for six and a half seasons (the Knicks).

“I was ready to walk away, yeah,” Anthony said. “It was hard. But there came a point when I was, like, ‘You know what? I’ve given a lot to this game. I played 15, 16 years in this game. I’m ready to give it up, because I just knew that at that point in time from a basketball standpoint, that narrative that it — it was already out there. So I’d been fightin’ an uphill battle anyway if I didn’t go to the right situation.”