Lens - ImageMagick cheatsheet 
This cheatsheet describes how ImageMagick CLI arguments and options map into corresponding Lens arguments and options.
Distortions 
Affine 
ImageMagick:
magick "<input-image>" -distort Affine "<control-points>" "<output-image>"Lens:
const { image: outputImage } = await distort(
  inputImage,
  "Affine",
  controlPoints
);AffineProjection 
ImageMagick:
magick "<input-image>" \
-distort AffineProjection "<sx>, <rx>, <ry>, <sy>, <tx>, <ty>" \
"<output-image>"Lens:
const { image: outputImage } = await distort(
  inputImage,
  "AffineProjection",
  [sx, rx, ry, sy, tx, ty]
);Arc 
ImageMagick:
magick "<input-image>" \
-distort Arc "<arc-angle>, <rotate-angle>, <outer-radius>, <inner-radius>" \
"<output-image>"Lens:
const { image: outputImage } = await distort(
  inputImage,
  "Arc",
  [arcAngle, rotateAngle, outerRadius, innerRadius]
);Perspective 
ImageMagick:
magick "<input-image>" -distort Perspective "<control-points>" "<output-image>"Lens:
const { image: outputImage } = await distort(
  inputImage,
  "Perspective",
  controlPoints
);PerspectiveProjection 
ImageMagick:
magick "<input-image>" \
-distort PerspectiveProjection "<sx>, <ry>, <tx>, <rx>, <sy>, <ty>, <px>, <py>" \
"<output-image>"Lens:
const { image: outputImage } = await distort(
  inputImage,
  "PerpsectiveProjection",
  [sx, ry, tx, rx, sy, ty, px, py]
);Resampling 
EWA 
EWA resampling is used by default in ImageMagick and Lens. 
Interpolated Color Lookup 
ImageMagick:
magick "<input-image>" \
-filter point \
-distort ...Lens:
distort(image, distortion, args, {
  preferredResampler: "point",
});Supersampling 
ImageMagick:
magick "<input-image>" \
-set option:distort:scale <factor> \
-distort ...Lens:
distort(image, distortion, args, {
  outputScaling: factor,
});Resample filter 
TIP
See list of supported filters.
ImageMagick:
magick "<input-image>" \
-filter <filter-name> \
-distort ...Lens:
distort(image, distortion, args, {
  filter: filterName,
});Virtual Pixel Method 
TIP
In following example "transparent" virtual pixel method is used for clarity. You can use any of supported methods. See list of supported virtual pixel methods.
ImageMagick:
magick "<input-image>" \
-virtual-pixel transparent \
-distort ...Lens:
import { distort, VirtualPixelMethod } from "@alxcube/lens";
// ...
distort(image, distortion, args, {
  virtualPixelMethod: VirtualPixelMethod.TRANSPARENT,
});Interpolation Method 
TIP
In following example "integer" virtual pixel method is used for clarity. You can use any of supported methods. See list of supported interpolation methods.
ImageMagick:
magick "<input-image>" \
-interpolate integer \
-distort ...Lens:
import { distort, InterpolationMethod } from "@alxcube/lens";
// ...
distort(image, distortion, args, {
  interpolationMethod: InterpolationMethod.INTEGER,
});Options 
Best-fit output viewport 
ImageMagick: (using +distort instead -distort)
magick "<input-image>" +distort ...Lens:
distort(image, distortion, args, {
  viewport: "bestFit",
});
// or
distort(image, distortion, args, {
  viewport: true,
});Custom output viewport 
ImageMagick:
magick "<input-image>" \
-define distort:viewport=<width>x<height>+<offset-x>+<offset-y> \
-distort ...Lens:
distort(image, distortion, args, {
  viewport: { width: width, height: height, x: offsetX, y: offsetY },
});
// or
distort(image, distortion, args, {
  viewport: {
    x1: offsetX,
    y1: offsetY,
    x2: offsetX + width - 1,
    y2: offsetY + height - 1,
  },
});Repage 
Set custom viewport 
ImageMagick:
magick "<input-image>" \
+distort <distortion> "<args>" \
-repage <width>x<height>+<offset-x>+<offset-y> \
"<output-image>"Lens:
distort(inputImage, distortion, args, {
  repage: { width: width, height: height, x: offsetX, y: offsetY },
  viewport: true,
});Set custom offset 
ImageMagick:
magick "<input-image>" \
+distort <distortion> "<args>" \
-repage +<offset-x>+<offset-y> \
"<output-image>"Lens:
distort(inputImage, distortion, args, {
  repage: [offsetX, offsetY],
  viewport: true,
});Reset offset 
ImageMagick:
magick "<input-image>" \
+distort <distortion> "<args>" \
+repage \
"<output-image>"Lens:
distort(inputImage, distortion, args, {
  repage: true,
  viewport: true,
});Image Background Color 
ImageMagick:
magick "<input-image>" \
-background <color> \
-distort ...Lens:
INFO
Lens supports color options in following formats:
- HEX (
"#ffffff","#fff") - HEXA (
"#ffffffff") - RGB (
"rgb(255, 255, 255)","rgb(100%, 100%, 100%)") - RGBA (
"rgba(255, 255, 255, 0.5)","rgba(100%, 100%, 100%, 1)") - Array: 
[255, 255, 255, 255] - Special string constant for transparent color: 
"transparent" 
distort(inputImage, distortion, args, {
  imageBackgroundColor: color,
});Matte Color 
ImageMagick:
magick "<input-image>" \
-mattecolor <color> \
-distort ...Lens:
INFO
Lens supports color options in following formats:
- HEX (
"#ffffff","#fff") - HEXA (
"#ffffffff") - RGB (
"rgb(255, 255, 255)","rgb(100%, 100%, 100%)") - RGBA (
"rgba(255, 255, 255, 0.5)","rgba(100%, 100%, 100%, 1)") - Array: 
[255, 255, 255, 255] - Special string constant for transparent color: 
"transparent" 
distort(inputImage, distortion, args, {
  matteColor: color,
});