使用gs更改pdf图像dpi

时间:2012-03-08 22:20:16

标签: unix image-processing ghostscript dpi

我正在尝试使用Linux / Ubuntu 11.10中的gs来更改.pdf图像(myPic.pdf)的dpi

这是我如何处理它但我得到错误:

 gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dPDFSETTINGS=/printer \
    -sOutputFile=fileout.pdf \
     myPic.pdf`

在这里,我尝试根据this

将dpi更改为300

尝试上述命令时收到的错误是:

**** Unable to open the initial device, quitting.

是什么给出了?

可能的解决方案:

检查this

2 个答案:

答案 0 :(得分:2)

您的初始Ghostscript命令应该有效。

但是,如果您所在的目录对于运行该命令的用户不可写,那么您将收到类似的消息!

mbp:/$ pwd
 /

mbp:/$ ls -ld .
 drwxr-xr-x  38 root  wheel  1360 Mar 10 16:20 .

mbp:/$ whoami
 pipitas

mbp:/$ gs -o a.pdf -sDEVICE=pdfwrite -c showpage
 GPL Ghostscript 9.05 (2012-02-08)
 Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
 This software comes with NO WARRANTY: see the file PUBLIC for details.
 GPL Ghostscript 9.05: **** Could not open the file a.pdf .
 **** Unable to open the initial device, quitting.

mbp:/$ cd ~

mbp:/$ pwd
 /Users/pipitas

mbp:~$ ls -ld .
 drwxr-xr-x+ 3010 pipitas  staff  102340 Mar 13 22:01 .

mbp:~$ gs -o a.pdf -sDEVICE=pdfwrite -c showpage
 GPL Ghostscript 9.05 (2012-02-08)
 Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
 This software comes with NO WARRANTY: see the file PUBLIC for details.

答案 1 :(得分:0)

这很有用!

convert -units PixelsPerInch myPic.pdf -density 300 fileout.pdf