linux - 使用ghostscript转换后如何防止白边

标签 linux shell ghostscript

我尝试使用 ghostscript 将 .eps 文件转换为 .png。

.eps 文件的分辨率为 1000x1000 像素。但是 outfile 的左侧和底部有白色的大边框。

gs -dNOPAUSE -dBATCH -r1000x1000 -q -sDEVICE=png256 -dDEVICEWIDTHPOINTS=880 -dDEVICEHEIGHTPOINTS=720 -sOutputFile=infile.png infile.eps

最佳答案

EPS 文件没有分辨率,因此它不可能有 1000x1000 的分辨率,尤其是 1000x1000 像素,因为那不是分辨率,它是尺寸。

我非常怀疑您要将分辨率设置为 1000 dpi,同时将媒体大小设置为 880 点 x720 点。这将导致 .png 12000x10000 像素。 (每英寸有 72 个点,这意味着您将 12x10 英寸的介质设置为每英寸 1000 点)

处理 EPS 文件(它与 PostScript 文件略有不同但很重要)的正确方法是自行安排缩放比例。

如果生成的图像的尺寸对您不重要,那么您可以使用 -dEPSCrop 生成图像,其中媒体的尺寸取自 EPS 文件中的注释。

如果您需要图像具有特定尺寸,那么您应该使用 -g 设置媒体大小(以像素为单位)、设置 -dFIXEDMEDIA 和设置 -dEPSFitPage,这将缩放 EPS 以适应媒体尺寸。

关于linux - 使用ghostscript转换后如何防止白边,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33276918/

相关文章:

linux - 使用 lsof 的脚本在 shell 上运行良好,而不是在 cron 上运行良好

linux - 在 "no such file"中查找带引号的命令结果

linux - 作业 : use number of words in one file(through wc) and send it to head as the number of lines

linux - 如何使用 ssh tail 命令写入本地文件

pdf - 使用 Ghostscript 将 PDF 渲染为 PNG 时,请遵守 PDF 中的 MediaBox/CropBox

linux - 如何将 Linux 命令放在括号中?

python - ': [Errno 2] No such file or directoryile ' in Linux

linux - 如何在 Linux 上的 upstart 脚本中复制文件?

pdf - 使用 ImageMagick 和/或 GhostScript 将多页 PDF 转换为多个 JPG

ghostscript - 什么是ghostscript,为什么要使用它?