1.0.7 • Published 9 months ago

@jobkhy/img-converter v1.0.7

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

Image Converter

Image Converter is a high-performance image conversion library written in Rust and exposed to Node.js using napi-rs. It allows you to convert images between multiple formats efficiently, either from file paths or buffers.

Features

  • 🚀 Fast image conversion powered by Rust
  • 🎨 Supports multiple formats: PNG, JPEG, BMP, GIF, TIFF
  • 🔧 Simple API for file-based and buffer-based conversions
  • 🛠️ Built with napi-rs for seamless Node.js integration

Installation

npm i @jobkhy/img-converter

Usage

CommonJS

const { convertImage, convertImageFile } = require("image-converter");

// Convert an image file
convertImage("input.jpg", "output.png", "png");

// Convert an image buffer
const fs = require("fs");
const inputBuffer = fs.readFileSync("input.jpg");
const outputBuffer = convertImageFile(inputBuffer, "png");
fs.writeFileSync("output.png", outputBuffer);

ES Modules

import { convertImage, convertImageFile } from "image-converter";

await convertImage("input.jpg", "output.png", "png");

import fs from "fs";
const inputBuffer = fs.readFileSync("input.jpg");
const outputBuffer = convertImageFile(inputBuffer, "png");
fs.writeFileSync("output.png", outputBuffer);

API

convertImage(inputPath: string, outputPath: string, format: string): Promise<void>

Converts an image file to the specified format and saves it to disk.

convertImageFile(inputData: Buffer, format: string): Buffer

Converts an image buffer to the specified format and returns a new buffer.

Supported Formats

  • PNG
  • JPEG / JPG
  • BMP
  • GIF
  • TIFF
  • WEBP

Requirements

  • Node.js 16+ (with N-API support)

License

MIT

1.0.7

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago