I want Latex to detect images that are larger than the page width and automatically scale them down to fit, similar to what this does:
\includegraphics[width=\textwidth]{path/to/image}
However, I also want it to detect when images are smaller than the page width, and not to perform any resizing, just displaying it at actual size.
Is there a way to do this automatically in Latex, without having to set it on each image manually? Currently with the above example it scales up smaller images far too large.