I have a general question, so without any example code.
I'm implementing part of document containing gallery of images.
Generally, I have two types of images:
1) document, typically scanned A4, which shall be displayed to full page, required scaling is to keep maximum width and detect the height: \includegraphics[width=\textwidth]{image.jpg}
2) photo, which shall be scaled down to maximize amount of images at one page - height is fixed and width is detected: \includegraphics[height=4cm]{image.jpg}
For most images it works OK, but for very rare exceptions I have problem with non-standard dimensions:
1) very high document which doesn't fit to page height if I specify width=\textwidth
2) very wide photo which doesn't fit to text width if I specify height=XXcm
Question is: how to implement something like below description?
1) width = \textwidth
if height fits page height, otherwise scale image (= keep aspect ratio) to image height = {page height - some spare buffer for caption}
2) height = {some height}
if width fits \textwidth, otherwise scale image to image width = \textwidth
Note: dimensions of images can vary from image to image and all above cases could be randomly in one chapter.
\includegraphics[width=\textwidth, height=.75\textheight,keepaspectratio]{..}