Shrink figure only when necessary?
Consider that you have this:
This will now take its original width, but if you want it to take up 100% of the text width you do it like this:
How about if you want to include images and use their original size if they fit, otherwise have it resized?
In this example, the second image should get
[width=\textwidth] because it is going to exceed the bounds of the document.