Ghostscript ps转为jpg输出,不带空白 [英] Ghostscript ps to jpg output without white space

查看:359
本文介绍了Ghostscript ps转为jpg输出,不带空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做的是使用ghostcript将只是图像的ps转换为jpg,这就是我开始的

What I am trying to do is convert a ps which is just a image to a jpg using ghostcript here is what I started with

gswin32c.exe -sDEVICE=jpeg -sOutputFile="test.png" example.ps

但是,当我运行此命令时,jpg在右侧和底部会出现很多空白

however when I run this the jpg comes out with a lot of white space to the right and the bottom

图片也很大,有没有办法在ghostscript中裁剪空白?

Also the picture comes out huge is there any way to crop out the whitespace in ghostscript?

我尝试了此代码

gswin32c.exe -sDEVICE=jpeg  -dBATCH -dNOPAUSE -dSAFER -r72x72 -g200x900 -sOutputFile="test.jpg" example.ps

减小宽度,但高度仍然很大。有解决方案吗?

which decrease the width but the height is still huge. Any solutions?

推荐答案

首先,您需要设置正确的媒体尺寸。有几种方法,包括您已经发现的-g开关。

Firstly you need to set the 'correct' media size. There are several methods, including the -g switch you have already discovered.

底部的空白(可能)是由文件的创建方式引起的, PostScript坐标从左下角开始,并随着页面的上移和右移而增加。许多计算机系统从左上角开始,并随着您的下降而增加。为了模仿这一点,文档可能会翻转垂直方向(这样,当您沿着页面向下移动时,值会增加),然后偏移初始点,使其开始于为其设计的媒体的左上方。

The white space at the bottom is caused (probably) by the way the file has been made, PostScript co-ordinates start at bottom left and increase as you go up the page and right. Many computer systems start at top left and increase as you go down. In order to mimic this the document probably 'flips' the vertical (so that values increase as you go down the page) and then offsets the initial point so that it starts at the top left of the media it was designed for.

您可以使用-c .... -f开关将PostScript添加到命令行中,您将需要添加某种垂直平移来移动成像的部分。根据原始PostScript中转换的完成方式,您可能需要添加正偏移量或负偏移量。我会尝试0 -100翻译,然后查看图像在输出上的移动方式。

You can add PostScript to the command line using the -c .... -f switches, you will want to add some kind of vertical translation to move the imaged portion. Depending how the translation was accomplished in the original PostScript you may need to add either a positive or a negative offset. I would try 0 -100 translate and then see which way the image moves on the output.

或者,将文件转换为PDF(使用pdfwrite设备)并应用CropBox。

Alternatively, convert the file to a PDF (using the pdfwrite device) and apply a CropBox.

这篇关于Ghostscript ps转为jpg输出,不带空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆