抱歉,这可能是也可能不是直接的编程问题,但我正在尝试使用 Imagemagick 和 Gimp 调整屏幕截图的大小以包含在 Beamer 演示文稿中,但结果比 由 LaTeX 完成调整大小。
例如,在 Beamer 中,我可能有一个命令来重新缩放图像 \includegraphics[width=.5\textwidth]{fig.png}
。使用类似的东西
\begin{frame}
\message{width = \the\textwidth}
\message{height = \the\textheight}
\end{frame}
我已经得到了 \textwidth
和 \textheight
参数(345.69548, 261.92444)。所以我有一个脚本(Python)向 Imagemagick 发送系统调用:
'convert %s -resize %.6f@ resized_%s' % (f,a,f)
其中 a
计算为 \textwidth*\textheight*0.5**2
和 f
是文件名。然后,当我返回到 Beamer 演示文稿并包含调整大小的图形 \includegraphics{resized_fig.png}
时,大小看起来大致正确,但非常模糊。我也尝试在 Gimp 中调整大小(使用 GUI),但也没有运气......帮忙?谢谢...
Sorry, this may or may not be a programming question directly, but I am trying to resize screenshots with Imagemagick and Gimp to include in a Beamer presentation, but it comes out even blurrier than the resizing done by LaTeX.
For instance, in Beamer I might have a command to rescale the image \includegraphics[width=.5\textwidth]{fig.png}
. Using something like
\begin{frame}
\message{width = \the\textwidth}
\message{height = \the\textheight}
\end{frame}
I have gotten the \textwidth
and \textheight
parameters in points (345.69548, 261.92444). So I have a script (in Python) that sends a system call to Imagemagick:
'convert %s -resize %.6f@ resized_%s' % (f,a,f)
where a
is calculated as \textwidth*\textheight*0.5**2
and f
is the file name. When I then go back into my Beamer presentation and include the resized figure, \includegraphics{resized_fig.png}
, the size looks approximately correct but it's super-blurry. I also tried resizing in Gimp (using the GUI) but no luck either... help? Thanks...
发布评论
评论(1)
如果您想保留像素清晰度,即不缩放和插值像素,而是将它们表示为小方块,我建议采用以下方法:
使用 sam2p。
照常将转换后的 EPS 或 PDF 包含在文档中。每个像素都只是一个小矩形框,它看起来清晰锐利,并且无需插值即可缩放。
例如,假设我们有一个小的光栅图像,我们想要显示它:
我们可以使用以下命令将其转换为矢量 PDF:
现在我们有一个矢量版本(其中每个像素都是一个矩形) ),我们可以将它包含在任何 LaTeX 文档中并自由缩放。所有像素都会缩放,但不会进行插值。
例如,
它看起来像这样:
缺点:
If you want to preserve pixel sharpness, i.e. do not scale and interpolate pixels, but represent them as small squares, I suggest this approach:
Convert you PNG image to EPS/PDF with sam2p.
Include converted EPS or PDF in your document as usual. Every pixel will be just a small rectangular box, it will look crisp and sharp, and will scale without interpolation.
For example, let's assume we have a small raster image, that we want to show:
We can convert it to vector PDF with this command:
Now as we have a vector version (where every pixel is a rectangular), we can include it in whatever LaTeX document and scale freely. All pixels will scale, but will not be interpolated.
For example,
This will look like this:
Drawbacks: