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

image-content-analyzer

v2.0.3

Published

A comprehensive image analysis library for detecting explicit content using skin detection and OCR text analysis

Downloads

607

Readme

Image Content Analyzer

npm version License: MIT TypeScript

A comprehensive Node.js library for analyzing images to detect explicit content. It now features a pluggable architecture, optional AI-based detection, and customizable OCR blocklists!

Features

  • Skin Detection (Heuristics): Fast RGB, normalized RGB, and HSV pixel analysis.
  • AI Detection (TensorFlow.js): Optional high-accuracy detection using nsfwjs.
  • OCR Text Analysis: Extract and analyze text from images using tesseract.js with customizable blocklists.
  • Pluggable Caching: Built-in Memory Cache with an ICacheAdapter interface to easily plug in Redis, Memcached, etc.
  • Batch Processing: Efficiently analyze multiple images concurrently.
  • Dual Build: Fully supports both CommonJS (CJS) and ES Modules (ESM).
  • TypeScript Support: Full TypeScript definitions included.

Detection Modes: Limitations & Accuracy

This library provides two primary modes of detection to help you balance execution speed and analytical accuracy depending on your specific use case.

Heuristic Mode (Fast)

  • Best for: High-volume batch processing, illustrations, and environments where execution speed is the absolute priority.
  • Limitations: This mode relies purely on pixel-level color space analysis (RGB, Normalized RGB, and HSV). Because it evaluates pixels in isolation without understanding the surrounding context, it is "color-blind." It is highly prone to false positives on earth tones. Objects like sunlit rocks, sand, wood grain, and warm lighting share the exact same hue and saturation wavelengths as human skin, which can cause these textures to be incorrectly flagged as explicit content.

AI Detection Mode (High Accuracy)

  • Best for: Complex, real-world photography and applications requiring strict accuracy.
  • Accuracy: By configuring detectionMode: 'ai', the analyzer uses TensorFlow.js and nsfwjs to evaluate edges, shapes, and contextual meaning. The AI understands the visual difference between a person and a beach scene, effectively eliminating the false positives caused by heuristic pixel matching.

Installation

npm

npm install image-content-analyzer

yarn

yarn add image-content-analyzer

pnpm

pnpm add image-content-analyzer

bun

bun add image-content-analyzer

AI Detection (Optional)

If you plan to use the AI detection mode, also install the peer dependencies:

# npm
npm install nsfwjs @tensorflow/tfjs-node

# yarn
yarn add nsfwjs @tensorflow/tfjs-node

# pnpm
pnpm add nsfwjs @tensorflow/tfjs-node

# bun
bun add nsfwjs @tensorflow/tfjs-node

Quick Start

import { analyzeImageFast, configureAnalyzer } from 'image-content-analyzer';

// (Optional) Configure global settings for V2 architecture
configureAnalyzer({
  detectionMode: 'ai', // Choose between 'heuristic' (fast) or 'ai' (accurate)
  // customOcrBlocklist: { custom: ['bannedword1', 'bannedword2'] }
});

// Analyze a single image
const result = await analyzeImageFast('https://example.com/image.jpg');
console.log(result.isExplicit); // boolean
console.log(result.confidence); // 0-1

Advanced Configuration

You can provide your own cache adapter to share state across clusters (e.g. Redis) by implementing the ICacheAdapter interface:

import { configureAnalyzer, type ICacheAdapter } from 'image-content-analyzer';

class RedisCacheAdapter implements ICacheAdapter {
  get<T>(key: string) { /* ... */ return null; }
  set<T>(key: string, data: T, ttlSeconds: number) { /* ... */ }
  delete(key: string) { /* ... */ }
  clear() { /* ... */ }
}

configureAnalyzer({
  cacheAdapter: new RedisCacheAdapter(),
  detectionMode: 'heuristic'
});

Contributing

Contributions are always welcome! Please see the CONTRIBUTING.md file for guidelines on how to get started.

License

MIT License. See the LICENSE file for more information.