@types/probe-image-size
TypeScript icon, indicating that this package has built-in type declarations

7.2.4 • Public • Published

Installation

npm install --save @types/probe-image-size

Summary

This package contains type definitions for probe-image-size (https://github.com/nodeca/probe-image-size#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/probe-image-size.

index.d.ts

/// <reference types="node" />

import needle = require("needle");
import { Transform } from "stream";

/**
 * Get image size without full download. Supported image types: JPG, GIF, PNG, WebP, BMP, TIFF, SVG, PSD.
 */
declare function probe(source: string, opts?: needle.NeedleOptions): Promise<probe.ProbeResult>;
declare function probe(source: NodeJS.ReadableStream, keepOpen?: boolean): Promise<probe.ProbeResult>;

declare class ProbeError extends Error {
    constructor(
        message: string,
        code?: "ECONTENT" | null,
        statusCode?: number,
    );
}

declare namespace probe {
    interface ProbeResult {
        width: number;
        height: number;
        length: number;
        type: string;
        mime: string;
        wUnits: string;
        hUnits: string;
        url: string;
        orientation?: Orientation | undefined;
        variants?: Variant[] | undefined;
    }

    type Orientation = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;

    interface Variant {
        width: number;
        height: number;
    }

    const Error: typeof ProbeError;

    function sync(data: Buffer): ProbeResult | null;

    // eslint-disable-next-line @typescript-eslint/no-empty-interface
    interface ParserStream extends Transform {}

    type Parser = () => ParserStream;

    interface Parsers {
        avif: Parser;
        bmp: Parser;
        gif: Parser;
        ico: Parser;
        jpeg: Parser;
        png: Parser;
        psd: Parser;
        svg: Parser;
        tiff: Parser;
        webp: Parser;
    }

    const parsers: Parsers;
}

export = probe;

Additional Details

Credits

These definitions were written by Jinesh Shah, and Piotr Błażejewicz.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/probe-image-size

Weekly Downloads

38,560

Version

7.2.4

License

MIT

Unpacked Size

6.18 kB

Total Files

5

Last publish

Collaborators

  • types