0.9.1 • Published 9 days ago

@e-mc/image v0.9.1

Weekly downloads
-
License
BSD 3-Clause
Repository
github
Last release
9 days ago

@e-mc/image

  • NodeJS 16
  • ES2020

General Usage

Interface

import type { IHost, ModuleConstructor } from "./index";
import type { IFileThread } from "./asset";
import type { CommandData, CropData, QualityData, ResizeData, RotateData, TransformOptions } from "./image";
import type { ImageModule } from "./settings";

interface IImage extends IClient<IHost, ImageModule> {
    resizeData?: ResizeData;
    cropData?: CropData;
    rotateData?: RotateData;
    qualityData?: QualityData;
    methodData?: [string, unknown[]?][];
    opacityValue?: number;
    setCommand(value: string | CommandData, outputAs?: string): void;
    getCommand(): string;
    parseCommand(value: string): CommandData;
    parseMethod(value: string): [string, unknown[]?][] | undefined;
    parseResize(value: string): ResizeData | undefined;
    parseCrop(value: string): CropData | undefined;
    parseRotate(value: string): RotateData | undefined;
    parseQuality(value: string): QualityData | undefined;
    parseOpacity(value: string): number;
    using?(data: IFileThread, command: string): Promise<unknown>;
    get outputAs(): string;
}

interface ImageConstructor extends ModuleConstructor {
    readonly REGEXP_SIZERANGE: RegExp;
    transform(file: string, command: string, options: { tempFile: true }): Promise<string>;
    transform(file: string, command: string, options?: TransformOptions): Promise<Buffer | null>;
    clamp(value: unknown, min?: number, max?: number): number;
    isBinary(mime: unknown): mime is string;
    toABGR(buffer: Uint8Array | Buffer): Buffer;
    readonly prototype: IImage;
    new(module?: ImageModule, ...args: unknown[]): IImage;
}

Settings

import type { PermittedDirectories } from "./core";

interface ImageModule {
    // handler: "@pi-r/jimp";
    webp?: string;
    settings?: {
        broadcast_id?: string | string[];
        cache?: boolean;
        jimp?: {
            exec?: {
                uid?: number;
                gid?: number;
            };
            cache_expires?: number | string;
            rotate_clockwise?: boolean;
        };
        webp?: {
            path?: string;
            cwebp?: string[];
            gif2webp?: string[];
        };
    };
    permission?: PermittedDirectories;
}

Example usage

NOTE: Usage without a Host is conducted through static methods. The using class method is called by the Host to perform the transformation.

References

LICENSE

BSD 3-Clause

0.8.9

9 days ago

0.8.8

10 days ago

0.7.6

9 days ago

0.7.5

10 days ago

0.8.10

9 days ago

0.6.3

10 days ago

0.7.4

10 days ago

0.5.6

10 days ago

0.9.1

9 days ago

0.9.0

11 days ago

0.8.7

1 month ago

0.6.2

1 month ago

0.7.3

1 month ago

0.5.5

1 month ago

0.8.6

2 months ago

0.7.2

2 months ago

0.5.4

2 months ago

0.6.1

2 months ago

0.8.5

2 months ago

0.8.4

3 months ago

0.8.3

3 months ago

0.8.2

3 months ago

0.8.1

4 months ago

0.8.0

5 months ago

0.7.1

5 months ago

0.7.0

5 months ago

0.6.0

9 months ago

0.5.3

12 months ago

0.5.2

1 year ago

0.5.1

1 year ago

0.5.0

1 year ago

0.4.2

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.3

1 year ago

0.3.2

1 year ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago