CaseLeaf

Handbook / The `picturefix` command

The picturefix command

A scanned exhibit went through the scanner at an angle and half the desk is in the photograph.

Crops or straightens a picture on a sheet. It is for the scan that went in at an angle, or the photograph with half a desk in it, where the fix belongs to the picture rather than to the page. The rest of the sheet is untouched.

How you run it

caseleaf picturefix report.pdf --page 1 --turn 0.02

caseleaf picturefix report.pdf --page 1 --crop 0.1,0.1,0.8,0.8

What each part means

In full, every part it will take:

caseleaf picturefix <file> [--page <n>] [--crop x,y,w,h] [--corners x1,y1,…,x4,y4] [--turn <radians>]
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. This command writes to it, so keep a copy if the original matters.
--page Which sheet, counting from 1, so --page 4 is the fourth sheet as it sits in the file, whatever number is printed on it. Left out, the first sheet.
--crop The part of the picture to keep, as four fractions of the picture itself from its bottom left. 0.1,0.1,0.8,0.8 keeps the middle eight tenths. Fractions rather than points, so the same crop suits a picture at any size.
--corners Four corners to pull square, as eight fractions of the picture in the order bottom left, bottom right, top right, top left. 0.02,0.05,0.98,0.01,0.99,0.95,0.03,0.99 suits a page photographed at a slight angle. Everything inside those corners is stretched back into a rectangle.
--turn Turn the picture, in radians, growing its canvas so no corner is cut off. 0.02 is about a degree, which is what a sheet fed slightly crooked needs.

Rescaling is not here: a picture is a mark, so its handles already do it.

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.

{
  "changed" : 1,
  "page" : 1,
  "written" : true
}

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 "picturefix" on "/path/to/report.pdf" ¬
        options "--page 1 --turn 0.02"
end tell

tell application "CaseLeaf"
    perform "picturefix" on "/path/to/report.pdf" ¬
        options "--page 1 --crop 0.1,0.1,0.8,0.8"
end tell

All the commands · Asking from a script · Contents