LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-14-2011, 11:41 PM   #1
ShellyCat
Member
 
Registered: Jul 2007
Distribution: Slackware 13
Posts: 178

Rep: Reputation: 29
Thumbs up TIP: Reducing PDF file size from the command line with GhostScript (gs)


I've spent hours trying to scan + shrink a multipage PDF document without losing readability. This is the first time I've ever needed to do this! (I had to scan each page as ".jpg" in order to email and open on another computer, so I could not scan to PDF directly, which I think is why each page was so large; lower DPIs made the text too blurry.)

I found this great tip on UbuntuGeek...but anyone can do this if GhostScript is installed:

http://www.ubuntugeek.com/ubuntu-tip...#comment-88401

Many thanks to whoever posted this tip!
 
Old 01-15-2011, 02:49 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,512

Rep: Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602
I tried it on a 139k text pdf and I got a 149k one! :-o.
 
Old 07-11-2012, 02:37 PM   #3
tolstoyleo
LQ Newbie
 
Registered: Jul 2012
Posts: 1

Rep: Reputation: Disabled
I know this is an old thread but this thread is at the top of a google search when looking to reduce file size, the command is:

Code:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
Some things that currently happen while running this command with the current apt-get install ghostscript version:

1: you need to specify a different output file name than the input file name, which is annoying, or else the outputted pdf will be blank / white.

2: if the pdf is not flattened (e.g. there's masked images), you'll get weird output, like missing backgrounds or missing images, what I ended up doing to fix this is using imagemagick's convert to jpg since jpg format doesn't have alpha channel (flat):

Code:
convert input.pdf input.jpg
Code:
convert input.jpg input.pdf
And then ran the ghostscript snippet above to reduce filesize, and so far that's been working for me well.

Hope this helps someone.
 
Old 07-12-2012, 04:11 AM   #4
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,512

Rep: Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602Reputation: 2602
Welcome to LQ

Thank you for the update for posterity. Please mention your ghostscript version. Post the output of
Quote:
gs -h | head -n 1
as there's a couple of different ghostscripts.
 
  


Reply

Tags
email, pdfs, resize, resolution, shrink


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PDF to Command line format Tux-O-Matic General 6 10-04-2006 07:05 AM
convert doc to pdf in command line yumener Linux - Software 4 04-28-2006 08:23 AM
Reducing file size using mencoder SithX Linux - Software 3 04-15-2005 08:56 PM
How can I read pdf files at the command line? hansi umayangan Linux - General 8 09-02-2004 07:27 AM
Ghostscript: why is pdf size sometimes increased so much? J_Szucs Linux - Software 2 08-27-2004 09:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration