A simple JavaScript class which converts a document photo to a scan-like image.
Far from perfect. Made for demo purposes.
PhotoScan(imageSource[, options])
- constructor
imageSource: string
: Source of the photooptions: { luminanceThreshold: number; grayscale: number; brightness: number }
(optional): Set of options for tuning the output scan- Default options:
luminanceThreshold
: 200,grayscale
: 1,brightness
: 1.5
- Default options:
PhotoScan.getCanvas()
- returns HTMLCanvasElement
of the scan
const scan = new PhotoToScan('./image.jpg');
const canvas = scan.getCanvas(); // Result canvas
// e.g. Append it as a child
element.appendChild(canvas);
MIT