[Tex/LaTex] Change default width of images in graphicx package

graphicsscaling

Is it possible to change the default width of an image included via \includegraphics (from the graphicx package) to a custom value, for example \linewidth.

So I want something like this:

\documentclass{article}

\usepackage[draft,width=\linewidth]{graphicx}

%or something like \setglobalimagewidth=\linewidth

\begin{document}

\includegraphics{test1} %width=\linewidth
\includegraphics[width=4cm]{test1} %width=4cm


\end{document}

Best Answer

Some options of package graphicx can be set using \setkeys:

\documentclass{article}
\usepackage{graphicx}
\setkeys{Gin}{width=\linewidth}

\begin{document}
  \noindent
  \includegraphics{test1}
\end{document}

What is Gin ? Documentation:

Here ‘Gin’ is the name used for the keyval keys associated with ‘Graphics inclusion`.

Related Question