<<>> <> <> <> <> <<>> DIRECTORY Commander, CommanderOps, Convert, FS, Imager, ImagerBox, ImagerMaskCapture, ImagerTransformation, InterpressInterpreter, IO, Rope, SF; InterpressSizeCommandImpl: CEDAR PROGRAM IMPORTS Commander, CommanderOps, Convert, FS, Imager, ImagerBox, ImagerMaskCapture, ImagerTransformation, InterpressInterpreter, IO ~ BEGIN InterpressSizeCommand: Commander.CommandProc ~ { ENABLE { FS.Error => { msg ¬ error.explanation; GOTO Failure; }; Convert.Error => { msg ¬ "Conversion error"; GOTO Failure; }; }; args: CommanderOps.ArgumentVector ~ CommanderOps.Parse[cmd]; IF args.argc # 2 THEN RETURN[$Failure, interpressSizeUsage] ELSE { m: Imager.Transformation ¬ ImagerTransformation.Scale[150.0/0.0254]; -- ~150 pixels/inch n: Imager.Transformation ¬ ImagerTransformation.PostScale[m, 0.0254]; -- back to inches master: InterpressInterpreter.Master ¬ InterpressInterpreter.Open[args[1], NIL]; FOR page: INT IN [1..master.pages] DO Operator: PROC [context: Imager.Context] ~ { Imager.SetColor[context, Imager.black]; Imager.SetStrokeEnd[context, square]; Imager.SetStrokeWidth[context, 0.0]; Imager.SetAmplifySpace[context, 1.0]; InterpressInterpreter.DoPage[master, page, context, NIL]; }; b: SF.Box ¬ ImagerMaskCapture.CaptureBounds[Operator, m ! ImagerMaskCapture.Cant => RESUME]; r: ImagerBox.Rectangle ¬ ImagerTransformation.InverseTransformRectangle[ n, ImagerBox.RectangleFromBox[[b.min.s, b.min.f, b.max.s, b.max.f]]]; IF master.pages > 1 THEN IO.PutF1[cmd.out, "P %g, ", IO.int[page]]; IO.PutFL[cmd.out, "origin: [%5.3f, %5.3f], width: %5.3f, height: %5.3f (inches)\n", LIST[IO.real[r.x], IO.real[r.y], IO.real[r.w], IO.real[r.h]]]; ENDLOOP; }; EXITS Failure => result ¬ $Failure; }; interpressSizeUsage: Rope.ROPE ~ " InterpressSize | IPSize Predict the (device independent) printed size of an interpress file. Although not performing unnecessary operations, the entire Interpress file is examined, which might take a long time."; Commander.Register["InterpressSize", InterpressSizeCommand, interpressSizeUsage]; Commander.Register["IPSize", InterpressSizeCommand, interpressSizeUsage]; END.