Appearance
Home > entanclature > router
router() function
*Route for different parameters.
Signature:
typescript
export declare function router(path: string, meta: Meta, opts: Opts): Promise<Result>;
Parameters
Parameter | Type | Description |
---|---|---|
path | string | The path of the image. |
meta | Meta | The meta information of the image. |
opts | Opts | The options for processing. |
Returns:
Promise<Result>
The result of the processing.
Remarks
You can't use this function directly. You need to use it through entanclature.
This function passes the parameter to the fromFile() as the parameter is a file path.
In this case, you should tell us how to handle the image (meta
) and manually specify the baseURL
and fileDir
.
Example
typescript
import { entanclature } from "entanclature";
import type { Meta, Opts } from "entanclature";
const filePath = "./path/for/an/image.png";
const meta = [
{ type: "image/png", quality: 80 },
{ type: "image/avif", quality: "+" },
{ type: "image/webp", quality: "-" },
];
const opts: Opts = {
baseURL: "https://example.com",
fileDir: "/images/",
};
const result = await entanclature(filePath, meta, opts);
console.log(result);