One way to go about this is by using the following fact:
For a vector space $V$, if $U$ and $W$ are subspaces of $V$, then their sum $U+V$ is a direct sum if and only if $U \cap W=\{0\}$.
Now since $T\in \mathcal{L}(V)$ we have that $\text{im}(T)$ is a subspace of $V$, and we are given that $W$ is a T-invariant subspace of $V$, so we can make the following conclusion:
$\text{im}(T) \cap W=\{0\}$
Given that $W$ is T-invariant, we have that for any $w\in W$, $T(w)\in W$. But we also know that $T(w)\in \text{im}(T)$. Given that we know their intersection is $\{0\}$ this means that $T(w)=0$, which by definition, means that each $w\in W$ is sent to $0$ by T, and therefore $W\subset N(T)$.
By the rank-nullity theorem we know that $\text{dim}(V)= \text{dim(im}(T))+\text{dim}(N(T))$. Since $V=\text{im}(T) \oplus W$, we also know that $\text{dim}(V)=\text{dim(im}(T)) +\text{dim}(W)$. This tells us that $\text{dim}(W)=\text{dim}(N(T))$.
Since $W\subset N(T)$ and their dimensions are equal, we must have that $W=N(T)$.