How lovell/sharp works
sharp is a Node-API image-processing library: callers create a Sharp instance from an image source, configure transformations and output format, then obtain a file, buffer, or stream. The JavaScript API is split across input, resize, compositing, operation, colour, channel, output, and utility modules; native C++ provides image loading and the processing pipeline. The README documents the user workflow and capabilities. Some JavaScript-to-native dispatch details and native helper calls are not visible in the excerpts, so those links are marked unverified.
Main entry points: index.mjs Sharp API · sharp.cc Native Binding · pipeline.cc Image Pipeline · input.mjs Input & Metadata
Components 18
JavaScript API
- Sharp API
lib/index.mjs - Instance Setup
lib/constructor.mjs - Input & Metadata
lib/input.mjs - Resize
lib/resize.mjs - Compositing
lib/composite.mjs - Image Operations
lib/operation.mjs - Colour Controls
lib/colour.mjs - Channel Controls
lib/channel.mjs - Output & Metadata
lib/output.mjs - Utilities & Stats
lib/utility.mjs
Native Engine
- Native Binding
src/sharp.cc - Image Pipeline
src/pipeline.cc - Native Operations
src/operations.cc - Image I/O Helpers
src/common.cc
Runtime Support
- Input Validation
lib/is.mjs - libvips Runtime
lib/libvips.mjs
Other components
- Application
- Image Result
Connections 24
- Application → Sharp API: creates image
README.md - Sharp API → Instance Setup: installs API
lib/index.mjs - Sharp API → Input & Metadata: installs input
lib/index.mjs - Sharp API → Resize: installs resize
lib/index.mjs - Sharp API → Compositing: installs compositing
lib/index.mjs - Sharp API → Image Operations: installs operations
lib/index.mjs - Sharp API → Colour Controls: installs colour
lib/index.mjs - Sharp API → Channel Controls: installs channels
lib/index.mjs - Sharp API → Output & Metadata: installs output
lib/index.mjs - Sharp API → Utilities & Stats: installs utilities
lib/index.mjs - Input & Metadata → Input Validation: validates with
lib/input.mjs - Resize → Input Validation: validates with
lib/resize.mjs - Image Operations → Input Validation: validates with
lib/operation.mjs - Input & Metadata → Native Binding: dispatches input
- Resize → Native Binding: dispatches resize
- Compositing → Native Binding: dispatches layers
- Image Operations → Native Binding: dispatches options
- Native Binding → Image Pipeline: routes calls
- Image Pipeline → Image I/O Helpers: opens inputs
src/pipeline.cc - Image Pipeline → Native Operations: uses operations
- Image Pipeline → Output & Metadata: returns output
- Output & Metadata → Image Result: produces image
README.md - Utilities & Stats → Native Binding: requests statistics
- Native Binding → libvips Runtime: loads runtime