Summary
Replace Jimp with sharp as the image processing library in spring-map-parser.
Why
| Capability |
Jimp |
sharp |
| Resampling |
Bilinear only |
Lanczos3, Mitchell, cubic, etc. |
| Large images |
Crashes on 10240×10240 JPEG (jpeg-js RangeError) |
Handles any size via libvips streaming |
| Performance |
Pure JS — slow encode/decode |
Native libvips — 10-50× faster |
| Format support |
JPEG, PNG, BMP, TIFF, GIF |
+ WebP, AVIF, HEIF |
| Memory usage |
Full RGBA buffer in JS heap |
Streams tiles, constant memory |
| Alpha handling |
Manual pixel manipulation |
Built-in .removeAlpha(), .ensureAlpha() |
Current Jimp usage in the parser
- 10×
ew Jimp(width, height) — buffer construction
- 1× Jimp.read() — skybox DDS decode
- 2× Jimp.intToRGBA /
gbaToInt — pixel color helpers
- All returned images are Jimp instances with .bitmap.data (raw RGBA Buffer)
All of these have direct sharp equivalents. The main API change is that sharp uses a pipeline pattern (sharp(input).resize().png().toBuffer()) rather than mutable bitmap objects.
Migration considerations
- Breaking change: Consumers currently receive Jimp objects. The return type would become sharp.Sharp or raw Buffer with metadata.
- Incremental path: Could first expose .bitmap.data raw buffers (already available on Jimp objects) as the public API, then swap internals to sharp. Downstream consumers like maps-metadata already bridge to sharp via raw buffers.
- Native dependency: sharp requires a native binary (pre-built for all major platforms via prebuild). This is standard for Node.js image processing but differs from Jimp's pure-JS approach.
- DDS decoding: Jimp.read() is used for skybox DDS files — would need a DDS decoder that outputs raw RGBA for sharp to consume (or keep a minimal DDS reader).
Related
Summary
Replace Jimp with sharp as the image processing library in spring-map-parser.
Why
Current Jimp usage in the parser
ew Jimp(width, height) — buffer construction
gbaToInt — pixel color helpers
All of these have direct sharp equivalents. The main API change is that sharp uses a pipeline pattern (sharp(input).resize().png().toBuffer()) rather than mutable bitmap objects.
Migration considerations
Related