我正在将 eps(Encapsulated PostScript)文件转换为带有 ghostscript 的 jpeg 文件。我使用的示例命令是:
gswin32.exe -sDEVICE=jpeg -dJPEGQ=100 -dNOPAUSE -dBATCH -dSAFER -r600x600 -dGraphicsAlphaBits=4 -dUseCIEColor -dEPSCrop -sOutputFile=”a.jpeg” b.eps
输入的 eps 文件带有白色背景(我只有它们的剪切路径)。我需要做的是在输出图像中将这个白色背景更改为另一种颜色,或者如果我能让它们透明会更好(输出文件格式为 png)。我怎样才能做到这一点?
最佳答案
我自己从未尝试过,但您应该可以通过设置将 eps 文件转换为 png:
-sDEVICE=pngalpha
pngalpha 设备也有一个 -dBackgroundColor 选项:
-dBackgroundColor=16#RRGGBB (RGB color, default white = 16#ffffff) For the pngalpha device only, set the suggested background color in the PNG bKGD chunk. When a program reading a PNG file does not support alpha transparency, the PNG library converts the image using either a background color if supplied by the program or the bKGD chunk. One common web browser has this problem, so when using on a web page you would need to use -dBackgroundColor=16#CCCC00 when creating alpha transparent PNG images for use on the page.
更多详情:Details of Ghostscript output devices见第 3.1 节。 PNG 文件格式
关于image-manipulation - 如何在将 eps 文件转换为 jpeg 或 png 时更改其背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2020972/