\documentclass[fontsize=13pt]{scrbook}
\tracinglostchars=3

\RequirePackage{graphicx}
\RequirePackage{hyperref}

\makeatletter
\newcommand{\maxwidth}{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
\newcommand{\maxheight}{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
\makeatother

% Scale images if necessary, so that they will not overflow the page margins by default
\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
