[Tex/LaTex] Turning off default scaling options (\setkeys{Gin}) temporarily

graphicspackages

To set the default scaling values for the \includegraphics command, one can use \setkeys{Gin}{(key)=value)} from the graphicx package. For example, say I put down

\setkeys{Gin}{width=.7\textwidth}

This will automatically scale all succeeding \includegraphics commands by the above width value. Is there a way to turn off this setting for certain graphics? That is, is there a way to still use \includegraphics without having the width set as the above?

I'm aware that

\begin{group}
\setkeys{Gin}{width=.7\textwidth}
\includegraphics{pizza.jpg} %this uses setted values
\end{group}
\includegraphics{pizza.jpg} %this uses normal values

works, but I'm wondering if I can do this without having to surround the \setkeys{Gin} command.

Best Answer

You can use the value stored in \Gin@nat@width, defining a handier interface to it:

\documentclass{article}
\usepackage{graphicx}

\setkeys{Gin}{width=30pt} % exaggerated for the example
\makeatletter
\let\ginnatwidth\Gin@nat@width
\makeatother

\begin{document}
\includegraphics{example-image-9x16}

\includegraphics[width=\ginnatwidth]{example-image-9x16}
\end{document}

enter image description here