Skip to content

Function: pickRotation()

ts
function pickRotation(
   image: {
  height: number;
  width: number;
}, 
   media: MediaDescriptor, 
   familyDirection: RotateDirection, 
   override?: 0 | 90 | 270 | "auto" | 180): 0 | 90 | 180 | 270;

Pick the rotation value to pass to renderImage / renderMultiPlaneImage.

Pure function — no IO, no driver state. The driver supplies its family-specific rotation direction; this helper combines that with the media's defaultOrientation hint and the caller's optional override to produce a single rotation angle.

Decision table:

  • override is set (and not 'auto') → returned verbatim.
  • media defaultOrientation === 'horizontal' and image is landscape (width > height) → return familyDirection.
  • everything else → 0 (pass through).

Parameters

ParameterTypeDescription
image{ height: number; width: number; }Source image dimensions.
image.heightnumber-
image.widthnumber-
mediaMediaDescriptorResolved media descriptor.
familyDirection?RotateDirectionDriver family's rotation direction.
override?0 | 90 | 270 | "auto" | 180Caller's per-print override. 'auto' means "use the heuristic" (same as omitted).

Returns

0 | 90 | 180 | 270