7 Replies Latest reply: Mar 22, 2011 7:33 AM by cathy fasano
cathy fasano Level 2 (340 points)
Following various tips, I have found that I can reduce the size of a pdf file from the command line via the command:

/System/Library/Printers/Libraries/./quartzfilter infile filterfile outfile

I have tested this on my 10.4 system, and it works like a charm. I have folded it into a perl script which I use to batch-reduce press-quality pdfs for viewing on the web.

But in 10.6 the command seems to have disappeared? I found a thread from Dec 09

http://discussions.apple.com/thread.jspa?messageID=10712296&#10712296

wondering if it was gone, and if no, what the heck happened to it, and if yes, is there any way to get it back? The poster then didn't get any answer -- is there anyone who can give any more information about it? I know that you can still reduce files in the 10.6 version of quartz using various interactive gui-controlled tools (although the pdf reduction is unreliable, I'm tinkering with it to see if I can get it to be acceptable), but I can't seem to figure out a command-line version which I would need for the script that runs at 2am.

macbook pro, Mac OS X (10.6.5)
  • baltwo Level 9 (62,215 points)
    Try a search for QuartzFilters. Apparently, moved with new Xcode Tools. Alternatively, copy it from Tiger and see if it'll run in SL.
  • Linc Davis Level 10 (192,275 points)
    You can apply Quartz filters with an Automator workflow or service, so there's little need for the command-line tool anymore.
  • baltwo Level 9 (62,215 points)
    Mind elaborating? AFAIK, there's no AppleScript command that does that.
  • Linc Davis Level 10 (192,275 points)
    Create a new workflow. Add the action "Apply Quartz Filter to PDF Documents." Select "Reduce File Size" from Filter menu.
  • baltwo Level 9 (62,215 points)
    Thanks for clarifying. I don't use it and wasn't sure it was going to be as easy as that.
  • Linc Davis Level 10 (192,275 points)
    The direct answer to your question is that there's good news and bad news. First, the bad news: quartzfilter is indeed gone, and it's not coming back. Now the good news: you can create an Automator workflow as described above, and then run it from the shell using the automator(1) command:
    NAME


    automator -- Runs Automator workflow.

    SYNOPSIS


    automator [-v] [-i input] [-D name=value ...] workflow

    DESCRIPTION


    automator runs the specified workflow. To create or edit a workflow, use
    the Automator application.

    The following options are available:

    -D name=value
    Set variable name to value for this run of workflow.

    -i input
    Set input as the input to workflow If input is - then the con-
    tents of standard input is used. The newline character ( ) is
    the delimiter for multiple strings.

    -v Run in verbose mode.
    I didn't know about this command until today.
  • cathy fasano Level 2 (340 points)
    The reason I need the command-line service is that I've got about 30 lines of perl which figure out what the reduced file should be named given the name of the press-quality file. This replaced 400 lines of almost-incomprehensible applescript that does the reduce-and-rename, that takes about 45 minutes to run versus 4 minutes for the perl script. From a programmer point of view, it's mighty convenient to just create and execute the reduce command at the end of the loop in the perl script.

    I guess I'll just have to keep a 10.4 machine around. Also, the reduction algorithm in 10.4 has proven itself rock-solid reliable over years of doing this, whereas the 10.6 pdf reduce file size fails spectacularly (as in the "reduced" file is 10-20 times the size of the original) about 5-10% of the time. I'll wait until all my PPC machines are on their last legs and then figure out what to do from there.