2

I'm currently working on a large-ish document that contains a lot of screenshots. These range from relatively small dialog boxes or details of the screen to some very large overview pictures. I currently use the option width=\textwidth for the larger screenshots to scale them down to fit the page (somewhat). I also need to apply some scaling to the other screenshots - some larger images need to be scaled down, some details need to be scaled up.

Now I would like to use a small set of scaling factors throughout the document. The screenshots are all taken from a single application, and I'd rather not have the font size and UI details change size from image to image. To achieve that, my current plan is to use only two or three fixed scaling factors throughout the document. I can apply these manually in the source code, but I need to determine the actual values first. For that, I was thinking about setting every image to width=\textwidth, recording the actual scaling applied and then classifying and adjusting the scaling factors.

As far as I can see, the original size and the requested size of each image file is contained in the log file, but on separate lines and in a syntax that is not very parser-friendly. Is there a better way to log the actual scaling factor that is applied to the image?

  • The term How to log scaling can be misunderstood as logarithmic scaling – user31729 Dec 30 '18 at 10:20
  • @ChristianHupfer I know that "science" is a verb now, but "to logarithmic" is a new one to me... – vwegert Dec 30 '18 at 10:22
  • to logarithmic is of course no verb (as long as I am not errant), but given some usual laziness with titles here, the title can be misunderstood at first – user31729 Dec 30 '18 at 10:24
  • If you use \adjustimage from the adjustbox package the previous width of the image is provided as \width dimension register which can be used with \ifdim\width>\somevalue etc. You could also just store the image in a box and take the box size as indicator (which is what adjustbox acutally does). – Martin Scharrer Dec 30 '18 at 10:29
  • and then there are the min width and max width keys provided by adjustbox which only scale if needed. Something like \adjustimage{min width=0.5\textwidth, max width=\textwidth}{image file name} will work to ensure that images are neither to small or to large. – Martin Scharrer Dec 30 '18 at 10:31
6

You could try this:

\documentclass{article}
\usepackage{graphicx}
\usepackage{etoolbox}
\makeatletter
\appto\GPT@setup@scale{\wlog{x-scale: \Gin@scalex, y-scale: \Gin@scaley}}
\begin{document}
\includegraphics[width=\textwidth]{example-image-duck}

\includegraphics[width=\textwidth]{example-image-a}

\end{document}

It will log

File: example-image-duck.pdf Graphic file (type pdf)
x-scale: 1.8696, y-scale: 1.8696

and

File: example-image-a.pdf Graphic file (type pdf)
x-scale: 1.07413, y-scale: 1.07413
  • I'm struggling to understand what's going on inside the graphics/graphicx packages. Is something similar to Gin@filename available...? – vwegert Dec 30 '18 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.