Resize screenshots / screenshots to include in Beamer

Sorry, this may or may not be a programming issue directly, but I'm trying to resize the screenshots with Imagemagick and Gimp to include them in the Beamer presentation, but this comes out even more rude than the resizing made by LaTeX .

For example, in Beamer, I might have a command to resize the image \includegraphics[width=.5\textwidth]{fig.png} . Using something like

 \begin{frame} \message{width = \the\textwidth} \message{height = \the\textheight} \end{frame} 

I got the \textwidth and \textheight in points (345.69548, 261.92444). So I have a script (in Python) that sends an Imagemagick system call:

 'convert %s -resize % .6f@ resized_%s' % (f,a,f) 

where a calculated as \textwidth*\textheight*0.5**2 , and f is the file name. When I go back to the Beamer presentation and add the modified shape, \includegraphics{resized_fig.png} , the size looks \includegraphics{resized_fig.png} good, but it's super-blurry. I also tried resizing in Gimp (using the GUI), but no luck ... help? Thanks...

+4
source share
1 answer

If you want to maintain the sharpness of the pixels, that is, not to scale or interpolate the pixels, but to represent them in the form of small squares, I suggest this approach:

  1. Convert PNG image to EPS / PDF using sam2p .

  2. Include the converted EPS or PDF in your document as usual. Each pixel will be a small rectangle, it will look crisp and clear and scaled without interpolation.

For example, suppose we have a small bitmap that we want to show:

10 × 10

We can convert it to vector PDF with this command:

 sam2p 10x10.png PDF: 10x10.pdf 

Now that we have the vector version (where each pixel is a rectangle), we can include it in any LaTeX document and scale it freely. All pixels will be scaled, but not interpolated.

For instance,

 \documentclass[12pt]{article} \usepackage[papersize={4cm,4cm},margin=2pt]{geometry} \usepackage{graphicx} \begin{document} \includegraphics[width=0.8\linewidth]{10x10.pdf} \end{document} 

It will look like this:

10 × 10 scaled without interpolation

Disadvantages:

  • The PDF version of the image is likely to be several times larger than its original PNG version.
+4
source

Source: https://habr.com/ru/post/1305646/


All Articles