npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kt-solutions/jscanify

v1.6.0

Published

Enhanced document scanner with multi-strategy detection. Fork of jscanify with improved accuracy for challenging backgrounds.

Downloads

136

Readme

@kt-solutions/jscanify

Enhanced JavaScript document scanner with multi-strategy detection for improved accuracy.

npm version License: MIT

Credits

This is an enhanced fork of jscanify by ColonelParrot. Full credit to the original author for creating this excellent document scanning library.

What's Enhanced? (v1.6.0)

This fork implements a Phase 10 Combined Detection Strategy that dramatically improves detection accuracy on challenging backgrounds:

| Original | This Fork | |----------|-----------| | Works well on solid backgrounds | Works on wood, stone, carpet, textured surfaces | | Single detection strategy | 6 parallel detection strategies | | Can detect internal elements (QR codes, text) as document edges | Geometric validation rejects non-rectangular shapes |

Detection Strategies

  1. Line-based (Hough Transform) - Best for documents with clear edges
  2. Contour-based (3 variants) - Standard, heavy blur, morphological gradient
  3. LAB Luminance - Color-space based edge detection
  4. Texture Contrast - Excellent for gray stone and textured surfaces
  5. Brightness Segmentation - Optimal for white paper detection
  6. Multi-scale Edge Detection - Tries multiple blur/threshold combinations

Geometric Validation

All detected shapes are validated with strict geometric constraints:

  • Width consistency: top edge ≈ bottom edge (max 30% difference)
  • Height consistency: left edge ≈ right edge (max 30% difference)
  • Rejects impossible/garbage shapes - prefers NO detection over BAD detection

Accuracy

Tested on 27 images across various backgrounds:

  • 93% detection rate (25/27 images)
  • Only fails on extreme white-on-white cases (physically limited contrast)

Installation

npm install @kt-solutions/jscanify

Usage

Node.js

const JScanify = require('@kt-solutions/jscanify');
const { loadImage } = require('canvas');

const scanner = new JScanify();

scanner.loadOpenCV(async (cv) => {
  const image = await loadImage('document.jpg');

  // Extract the document (perspective corrected)
  const result = scanner.extractPaper(image, 800, 1000);

  // Or just highlight the detected document
  const highlighted = scanner.highlightPaper(image);
});

Browser

<script src="https://docs.opencv.org/4.7.0/opencv.js" async></script>
<script src="node_modules/@kt-solutions/jscanify/src/jscanify.js"></script>

<script>
  const scanner = new jscanify();

  // Wait for OpenCV to load
  cv['onRuntimeInitialized'] = () => {
    const image = document.getElementById('myImage');
    const result = scanner.extractPaper(image, 800, 1000);
    document.body.appendChild(result);
  };
</script>

Configuration

const scanner = new JScanify({
  maxWidthDiff: 0.30,    // Max top/bottom width difference (30%)
  maxHeightDiff: 0.30,   // Max left/right height difference (30%)
  minAreaRatio: 0.08,    // Minimum document area (8% of image)
  maxAreaRatio: 0.95,    // Maximum document area (95% of image)
});

API

findPaperContour(img)

Finds the document contour in an image. Returns the contour with metadata about which strategy was used.

highlightPaper(image, options)

Highlights the detected document with a colored border.

  • options.color - Border color (default: "orange")
  • options.thickness - Border thickness (default: 10)

extractPaper(image, width, height, cornerPoints?)

Extracts and perspective-corrects the detected document.

  • width - Output width in pixels
  • height - Output height in pixels
  • cornerPoints - Optional custom corner points

getCornerPoints(contour)

Returns the four corner points of a detected contour:

  • topLeftCorner, topRightCorner, bottomLeftCorner, bottomRightCorner

Original jscanify

For the original library, visit:

License

MIT License - Same as original jscanify

Copyright (c) ColonelParrot (original), KT Solutions (enhancements)