
Security News
Package Maintainers Call for Improvements to GitHub’s New npm Security Plan
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
@fuuck/blurest-core
Advanced tools
A high-performance TypeScript/Node.js library for generating and caching [Blurhash](https://blurha.sh/) placeholders for images. This library provides a integration between JavaScript and a Rust module for optimal performance, with built-in database cachi
A high-performance TypeScript/Node.js library for generating and caching Blurhash placeholders for images. This library provides a integration between JavaScript and a Rust module for optimal performance, with built-in database caching to avoid redundant processing.
npm install @fuuck/blurest-core
# or
yarn add @fuuck/blurhash-core
# or
bun add @fuuck/blurhash-core
import { BlurhashCore } from "@fuuck/blurest-core";
// Initialize the core
const blurhash = new BlurhashCore({
databaseUrl: join(__dirname, "db.sqlite3"),
projectRoot: __dirname,
});
// Initialize the cache system
blurhash.initialize();
// Process an image
const result = blurhash.processImage("./images/photo.jpg");
if (result && result.success) {
console.log("Blurhash:", result.blurhash);
console.log("Dimensions:", result.width, "x", result.height);
} else if (result && !result.success) {
console.error("Error:", result.error);
}
// Cleanup when done
blurhash.cleanup();
new BlurhashCore(options: BlurhashCoreOptions)
Options:
databaseUrl
: Path of the database file, will be created if it doesn't existprojectRoot
: Absolute path to your project root directoryinitialize(): void
Initializes the blurhash cache system. Must be called before processing any images.
blurhash.initialize();
isInitialized(): boolean
Checks if the core is properly initialized.
if (blurhash.isInitialized()) {
// Ready to process images
}
processImage(src: string): BlurhashResult | null
Processes an image and returns blurhash data. Returns null
if the image should be skipped.
const result = blurhash.processImage("./images/photo.jpg");
Returns:
BlurhashSuccessResult
on successBlurhashErrorResult
on errornull
if processing should be skippedcleanup(): boolean
Cleans up resources and closes database connections.
blurhash.cleanup();
getProjectRoot(): string
Returns the configured project root path.
parseImageSrc(src: string): ParsedImageSource
Parses image source strings with optional dimension specifications.
import { parseImageSrc } from "@fuuck/blurest-core";
// Examples:
parseImageSrc("image.jpg =100x200"); // { cleanSrc: 'image.jpg', renderWidth: 100, renderHeight: 200 }
parseImageSrc("image.jpg =100x"); // { cleanSrc: 'image.jpg', renderWidth: 100, renderHeight: null }
parseImageSrc("image.jpg =x200"); // { cleanSrc: 'image.jpg', renderWidth: null, renderHeight: 200 }
parseImageSrc("image.jpg"); // { cleanSrc: 'image.jpg', renderWidth: null, renderHeight: null }
validateFile(src: string, projectRoot: string): FileValidationResult
Validates whether a file should be processed by the native module.
import { validateFile } from "@fuuck/blurest-core";
const validation = validateFile("./image.jpg", "/project/root");
if (validation.shouldProcess) {
console.log("File can be processed:", validation.resolvedPath);
} else {
console.log("Skipping file:", validation.reason);
}
isNetworkUrl(src: string): boolean
Checks if a URL is a network URL (HTTP/HTTPS).
import { isNetworkUrl } from "@fuuck/blurest-core";
isNetworkUrl("https://example.com/image.jpg"); // true
isNetworkUrl("./local/image.jpg"); // false
interface BlurhashSuccessResult {
success: true;
blurhash: string;
width: number;
height: number;
}
interface BlurhashErrorResult {
success: false;
error: string;
}
type BlurhashResult = BlurhashSuccessResult | BlurhashErrorResult;
interface BlurhashCoreOptions {
databaseUrl: string;
projectRoot: string;
}
interface ParsedImageSource {
cleanSrc: string;
renderWidth: number | null;
renderHeight: number | null;
}
interface FileValidationResult {
shouldProcess: boolean;
resolvedPath?: string;
reason?: string;
}
import { BlurhashCore } from "@fuuck/blurest-core";
const core = new BlurhashCore({
databaseUrl: join(__dirname, "db.sqlite3"),
projectRoot: __dirname,
});
core.initialize();
// Process a single image
const result = core.processImage("./src/assets/hero-image.jpg");
if (result?.success) {
console.log(`Generated blurhash: ${result.blurhash}`);
console.log(`Image dimensions: ${result.width}x${result.height}`);
}
import { BlurhashCore } from "@fuuck/blurest-core";
import { glob } from "glob";
const core = new BlurhashCore({
databaseUrl: join(__dirname, "db.sqlite3"),
projectRoot: __dirname,
});
core.initialize();
// Process all images in a directory
const imageFiles = glob.sync("./src/assets/**/*.{jpg,jpeg,png,webp}");
const results = imageFiles.map((file) => {
const result = core.processImage(file);
return { file, result };
});
console.log(`Processed ${results.length} images`);
core.cleanup();
import { BlurhashCore, parseImageSrc } from "@fuuck/blurest-core";
const core = new BlurhashCore({
databaseUrl: join(__dirname, "db.sqlite3"),
projectRoot: __dirname,
});
core.initialize();
function processMarkdownImage(src: string) {
// Parse image source for dimensions
const { cleanSrc, renderWidth, renderHeight } = parseImageSrc(src);
// Get blurhash for the clean source
const blurhashResult = core.processImage(cleanSrc);
if (blurhashResult?.success) {
return {
src: cleanSrc,
blurhash: blurhashResult.blurhash,
intrinsicWidth: blurhashResult.width,
intrinsicHeight: blurhashResult.height,
renderWidth,
renderHeight,
};
}
return null;
}
// Usage
const imageData = processMarkdownImage("./images/photo.jpg =800x600");
The library provides comprehensive error handling:
try {
core.initialize();
const result = core.processImage("./image.jpg");
if (result === null) {
console.log(
"Image processing was skipped (likely a network URL or invalid path)"
);
} else if (!result.success) {
console.error("Blurhash generation failed:", result.error);
} else {
console.log("Success:", result.blurhash);
}
} catch (error) {
console.error("Initialization or processing error:", error);
} finally {
core.cleanup();
}
The library automatically validates files before processing:
MIT
FAQs
A high-performance TypeScript/Node.js library for generating and caching [Blurhash](https://blurha.sh/) placeholders for images. This library provides a integration between JavaScript and a Rust module for optimal performance, with built-in database cachi
We found that @fuuck/blurest-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.