CaseLeaf

Handbook / The `pictures` command

The pictures command

A twelve-page brochure is somehow ninety megabytes and cannot be emailed, and you need to know which image is responsible.

Lists every picture in the document, or on one sheet if you name one, and how finely each is stored. A scanned document is often several times larger than it needs to be because of one oversized image, and this is how you find which. It is the survey that comes before smaller, which is what actually reduces them.

How you run it

caseleaf pictures report.pdf

caseleaf pictures report.pdf --page 1 --at 72,540 --dpi 150 --quality 0.8 --to reviewed.pdf

What each part means

In full, every part it will take:

caseleaf pictures <file> [--page <n>] [--at x,y] [--dpi <n>] [--quality <0-1>] [--to <file>]
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.
--at Report only the picture under this point, as x,y in points from the foot of the sheet, such as 420,560. A semicolon or a space separates them just as well. Left out, every picture is reported.
--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.
--to Where to write the re-encoded picture, once --page and --dpi are both given. Only the folder in this path is used, and what lands there is named picture-1.jpg and a viewable preview-1.png, not the path itself. Left out, nothing is written and the reply still says what the setting would cost. The document you named is never changed either way.
--page Which sheet to ask about, counting from 1. Left out, the whole document is reported instead, as a total for every picture rather than one sheet's.

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.

{
  "bytes" : 83940,
  "found" : 2,
  "left alone" : 0,
  "pages carrying pictures" : [
    1
  ],
  "pictures" : [
    {
      "bytes" : 83172,
      "dpi" : 132,
      "drawn across" : 260,
      "left alone" : false,
      "on pages" : [
        1
      ],
  … and the rest of the answer

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 "pictures" on "/path/to/report.pdf"
end tell

tell application "CaseLeaf"
    perform "pictures" on "/path/to/report.pdf" ¬
        options "--page 1 --at 72,540 --dpi 150 --quality 0.8 --to reviewed.pdf"
end tell

All the commands · Asking from a script · Contents