Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 617
dearN Avatar asked Oct 18 '25 12:10

dearN


1 Answers

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.
like image 72
Kurt Pfeifle Avatar answered Oct 21 '25 06:10

Kurt Pfeifle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!