easy-img
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Easy-Img

A simplified image manipulation package similar to canvas, providing easy-to-use functions for image editing.

Installation

npm install easy-img

Usage

Importing The Functions and Classes

TypeScript:

import { Editor, Font, load_image_async, saveCanvasToFile, load_image } from 'easy-img';

JavaScript:

const { load_image_async, Editor, Font, saveCanvasToFile } = require('easy-img');

Example Code

Asynchronous Usage

(async () => {
    const background = new Editor("space.png").resize(800, 250);

    const avatar = await load_image_async('path/to/avatar.png');
    const circle_avatar = new Editor(avatar).resize(200, 200).circle_image();
    background.paste(circle_avatar, 25, 25);

    const big_text = Font.poppins(50, 'bold');
    const small_text = Font.poppins(30, 'regular');

    background.text([490, 50], "Author Name", { color: "white", font: big_text, align: "center" });
    background.text([490, 125], "You have 55 XP and are level 2", { color: "#00ced1", font: small_text, align: "center" });

    const canvas = background.getCanvas();
    saveCanvasToFile(canvas, 'output.png');
})();

Synchronous Usage

(() => {
    const background = new Editor("space.png").resize(800, 250);

    const avatar = load_image('path/to/avatar.png');
    const circle_avatar = new Editor(avatar).resize(200, 200).circle_image();
    background.paste(circle_avatar, 25, 25);

    const big_text = Font.poppins(50, 'bold');
    const small_text = Font.poppins(30, 'regular');

    background.text([490, 50], "Author Name", { color: "white", font: big_text, align: "center" });
    background.text([490, 125], "You have 55 XP and are level 2", { color: "#00ced1", font: small_text, align: "center" });

    const canvas = background.getCanvas();
    saveCanvasToFile(canvas, 'output.png');
})();

Package Sidebar

Install

npm i easy-img

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

32.4 kB

Total Files

11

Last publish

Collaborators

  • verleihnix