qrimzn
v1.1.10
Published
Simple image processing and modifying library with limited functionality
Downloads
21,565
Readme
qrimzn
Pronounced: "crimson" /ˈkrɪmzən/
Etymology: qr (QR code) + im (image) + zn (resize) = qrimzn 🎨
A fast image processing library that provides QR code generation with custom labels and image resizing capabilities. The library uses a Go binary under the hood for high performance without requiring native dependencies. 🚀 The go library is called by spawning a child process. After the process is spawned, the child process is killed. Currently, the library supports very limited functionality. Any contributions are welcome.
Features
- QR Code Generation: Create QR codes with custom content and labels
- Image Resizing: Resize images with aspect ratio preservation
- No Native Dependencies: Unlike Sharp, no additional packages needed for Alpine Linux
- Cross-platform Support: Linux, macOS, Windows
- Multiple Architectures: amd64, arm64
- High Performance: Go binary with optimized image processing
- Memory Efficient: Processes images as streams
- Format Support: Supports JPEG, PNG input; outputs PNG
Installation
npm install qrimznThe installation will automatically download the appropriate binary for your platform.
Usage
QR Code Generation
import { createQrCode } from "qrimzn";
// Generate a QR code
const buffer = await createQrCode("https://example.com", "ABC12345678");
// Save to file
import fs from "fs";
fs.writeFileSync("qr.png", buffer);
// Or upload to cloud storage, etc.Image Resizing
import { resizeImage } from "qrimzn";
import fs from "fs";
// Read an image file
const imageBuffer = fs.readFileSync("input.jpg");
// Resize to 400px width (height calculated automatically to maintain aspect ratio)
const resized400 = await resizeImage(imageBuffer, 400);
fs.writeFileSync("output-400.png", resized400);
// Multiple sizes
const sizes = [400, 800, 1200];
const resizedImages = await Promise.all(
sizes.map((width) => resizeImage(imageBuffer, width))
);
// Works with any image format (JPEG, PNG, etc.) - outputs PNGReplacing Sharp
// Before (with Sharp - requires native dependencies)
import sharp from "sharp";
const resized = await sharp(buffer)
.resize({ width: 400, withoutEnlargement: true, fit: sharp.fit.inside })
.toBuffer();
// After (with qrimzn - no native dependencies)
import { resizeImage } from "qrimzn";
const resized = await resizeImage(buffer, 400);API
createQrCode(content: string, code: string): Promise<Buffer>
Generate a QR code with a custom label.
content: The content to encode in the QR code (typically a URL)code: The label text to display below the QR code- Returns: A Promise that resolves to a Buffer containing the PNG image data
resizeImage(buffer: Uint8Array | Buffer, width: number): Promise<Buffer>
Resize an image while maintaining aspect ratio.
buffer: Image data as Buffer or Uint8Array (supports JPEG, PNG, and other formats)width: Target width in pixels (height is calculated automatically)- Returns: A Promise that resolves to a Buffer containing the resized PNG image data
Features:
- Maintains aspect ratio automatically
- Never enlarges images (withoutEnlargement: true behavior)
- Uses high-quality BiLinear interpolation
- Memory efficient streaming processing
- No native dependencies required
Development
Building the Go binary
The Go binary is built automatically using GitHub Actions. To build manually:
cd go
go mod tidy
go build -o qrimzn main.goRelease Process
- Update version in
package.json - Run the build and release script:
./scripts/release.sh v1.0.0 - The script will:
- Build binaries for all supported platforms
- Create compressed archives
- Upload to GitHub releases
Manual Installation Testing
To test the installation script without publishing:
node scripts/install.jsNote: This requires a corresponding GitHub release to exist.
Manual Testing in Node.js
yarn build
# this will create a tar.gz file in the root folder
npm pack
# go to nodejs project in install it
npm install /Users/my-user/Desktop/libraries/qrimzn/qrimzn-1.1.0.tgz -w package-namePlatform Support
- Linux: amd64, arm64
- macOS: amd64, arm64
- Windows: amd64
License
MIT
