Appearance
Home > entanclature > fromFile
fromFile() function
*Process the image from the file path.
Signature:
typescript
export declare function fromFile(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.
await
is required for this function, because we need to calculate the SHA-1 of the file.
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.fromURL(filePath, meta, opts);
console.log(result);