This question stems from this question on Mathematics stack exchange. The top answer there provides a geometric solution; I'm curious though about an algebro-geometric solutions.
Let me rephrase that question a bit: Let $V$ be a variety in affine $n$-space $A^n_k$, over field $k$, given by an ideal $I$. How one would derive from $I$ the subgroup $G$ of affine transformations that leave $V$ invariant?
In particular, if $V$ is a hypersurface and $I$ is a principal ideal $(f)$ what properties of $f$ determine $G$?