CaseLeaf

Handbook / The `smaller` command

The smaller command

The same brochure has to go out today and the mail server refuses anything over ten megabytes.

Writes a copy whose pictures are no finer than the resolution you ask for. Documents built from scans carry images at far higher resolution than anything they will be used for, and the file size follows. Ask pictures what is there first, then use this with a figure that suits how the document will be read. The original is untouched, and the copy is what shrinks.

How you run it

caseleaf smaller report.pdf --to reviewed.pdf

caseleaf smaller report.pdf --to reviewed.pdf --dpi 150 --quality 0.8

What each part means

In full, every part it will take:

caseleaf smaller <file> --to <file> [--dpi <n>] [--quality <0-1>]
part what it is for
<file> The PDF to work on, as a path, such as report.pdf beside you, or the full path to it. It is read and not written.
--to Where to write the result, as a path. The shape above shows which format this command writes. This command needs it, and writes only there: the document you named is left exactly as it was.
--dpi Dots per inch to keep pictures at. 150 is right for reading on screen, 300 for printing; a scan is often stored at 600 and rarely needs to be.
--quality How hard to compress a picture, from 0, small and rough, to 1, large and faithful. 0.8 is the usual trade.

What comes back

Asked of a short sample document, it answers as below. The sample has eight sheets, a highlight and a note left by a reviewer, a web link, a small table, two pictures and one form field already filled in.

{
  "dpi" : 72,
  "keptTheOriginal" : false,
  "now" : 9963,
  "quality" : 0.40000000000000002,
  "rewritten" : false,
  "was" : 90875,
  "wrote" : "reviewed.pdf"
}

The same thing from AppleScript

Everything above can be asked for from a script instead. There is one AppleScript command, perform: on names the document, and options takes the rest exactly as you would type it.

tell application "CaseLeaf"
    perform "smaller" on "/path/to/report.pdf" ¬
        options "--to reviewed.pdf"
end tell

tell application "CaseLeaf"
    perform "smaller" on "/path/to/report.pdf" ¬
        options "--to reviewed.pdf --dpi 150 --quality 0.8"
end tell

All the commands · Asking from a script · Contents