1.2.1 • Published 10 months ago

nravif v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

nravif 🔥

npm version

Convert images to AVIF super fast and make friends with Rust along the way! 🚀🦀

High-performance AVIF converter powered by Rust's ravif, offering native-speed conversions with minimal memory footprint. Outperforms JavaScript-based solutions like Sharp by 3-5x in benchmark tests.

Features ✨

  • Blazing fast conversions using Rust-native code
  • 🦀 Memory-safe implementation via Rust bindings
  • 🖼️ Lossy/lossless compression support
  • 📈 Tunable quality/speed parameters
  • 🧩 Dual CJS/ESM module support
  • 🛡️ TypeSafe TypeScript definitions included

Installation 📦

npm install nravif

Quick Start 🚀

import { convertToAvifSync } from "nravif";
import fs from "fs/promises";

// Function to convert an image to AVIF format and save it to a file
async function convertAndSave() {
  try {
    // Define the input image file
    const inputFile = "input.jpg";
    // Define the output AVIF file name
    const outputFile = "output.avif";
    // Set AVIF conversion quality (0-100) and speed (0-10)
    const quality = 50;
    const speed = 4;

    console.log(`Converting ${inputFile} to AVIF format...`);

    // Convert the image to AVIF format, returns a Buffer
    const avifBuffer = await convertToAvifSync(inputFile, quality, speed);

    // Save the AVIF buffer to an output file
    await fs.writeFile(outputFile, avifBuffer);

    console.log(`✅ AVIF file saved successfully: ${outputFile}`);
  } catch (error) {
    // Handle any errors that occur during conversion or saving
    console.error("❌ Error converting image:", error);
  }
}

// Run the conversion function
convertAndSave();

GitHub Repository 🔗

👉 View on GitHub

Contributing 🤝

We welcome contributions! Please follow these guidelines:

  • Rust Code - Modify .rs files in /native
  • TypeScript - Update files in /src

Platform Support 🖥️

PlatformSupported
macOS (Darwin)✅ Yes
Windows✅ Yes
Linux⏳ Coming Soon

💡 Credits

This project is built using the following awesome technologies:

  • ravif - Rust-based AVIF encoder
  • neon-rs - Native bindings for Rust in Node.js
  • Rust - Systems programming language used for performance
  • Microbundle - Zero-config bundler for modern JavaScript libraries

License 📄

MIT © Ashutosh Bodade

Made with 🦀 Rust + ❤️ JavaScript

1.2.1

10 months ago

1.2.0

10 months ago

1.1.9

10 months ago

1.1.8

10 months ago

1.1.7

10 months ago

1.1.6

10 months ago

1.1.5

10 months ago

1.1.4

10 months ago

1.1.3

10 months ago

1.1.2

10 months ago

1.1.1

10 months ago

1.1.0

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago