Use \dimexpr
(provided by the e-TeX extensions whose availability is standard in LaTeX nowadays):
\includegraphics[width=\dimexpr.5\textwidth*(#1)\relax]{frog.jpg}
Be aware that in case of multiplication the formal syntax of \dimexpr
requires the dimension to come first and the scaling-factor to come last, nested in parentheses in case it is formed by a numerical expression. E.g.,
\dimexpr(.5\textwidth)*(#1)\relax
does work if #1
forms a valid numerical expression while
\dimexpr(#1)*(.5\textwidth)\relax
does not.
If #1
shall not necessarily be an integer, then scale the \dimexpr
itself:
\includegraphics[width=#1\dimexpr.5\textwidth\relax]{frog.jpg}
or
\includegraphics[width=.5\dimexpr#1\textwidth\relax]{frog.jpg}