Search code examples
uniximage-processingghostscriptdpi

Changing pdf image dpi using gs


I am trying to change the dpi of a .pdf image (myPic.pdf) using gs in Linux/Ubuntu 11.10

Here's how I am going about it but I get errors:

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

Here, I am attempting to change the dpi to 300 as per this

The error that I receive when I try the above command is:

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

What gives?

Possible solution:

Check this out.


Solution

  • Your initial Ghostscript command should work.

    However, if you are in a directory which is not writeable for the user running the command, you'll get a message like that!

    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.