You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/api/bun.md
+32-16
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# openimg/bun
2
2
3
-
openimg/bun (Open Image Bun) provides an HTTP request handler function to optimize images using sharp, using Bun APIs where possible. It also provides utilities for generating low quality image placeholders and retrieving image metadata.
3
+
openimg/bun (Open Image Bun) provides an HTTP request handler function to optimize images with [sharp](https://sharp.pixelplumbing.com), using Bun APIs where possible. It also provides utilities for generating low quality image placeholders and retrieving image metadata.
4
4
5
5
## Features
6
6
@@ -12,19 +12,13 @@ You can find the API reference for each function below.
12
12
13
13
## Installation
14
14
15
-
The code is available via `openimg/bun` and `openimg-bun`. For most use cases, you probably want to install `openimg`:
15
+
The code is available via `openimg/bun`:
16
16
17
17
```bash
18
18
npm i sharp openimg
19
19
```
20
20
21
-
However, if you only want to use the server-side utilities for Bun, you can also install `openimg-bun`:
22
-
23
-
```bash
24
-
npm i sharp openimg-bun
25
-
```
26
-
27
-
openimg package uses [sharp](https://sharp.pixelplumbing.com) and can only be used in environments that can run sharp (and [libvips](https://github.com/libvips/libvips)).
21
+
Note, openimg uses [sharp](https://sharp.pixelplumbing.com) and can only be used in environments that can run sharp (and [libvips](https://github.com/libvips/libvips)).
Import `getImgPlaceholder` from `openimg/bun` and pass in a Readable stream (like `ReadStream`) or image Buffer. The function will return a low quality image placeholder as a base64-encoded string using [thumbhash](https://github.com/evanw/thumbhash). The generated string can be stored in a database or inlined in your client bundle as a placeholder until the full image is loaded.
251
+
Import `getImgPlaceholder` from `openimg/bun` and pass in a Readable stream (like `ReadStream`), a ReadableStream, or image Buffer. The function will return a low quality image placeholder as a base64-encoded string using [thumbhash](https://github.com/evanw/thumbhash). The generated string can be stored in a database or inlined in your client bundle as a placeholder until the full image is loaded.
Import `getImgMetadata` from `openimg/bun` and pass in a Readable stream (like `ReadStream`) or image Buffer. The function will return the width, height, and format of the image.
288
+
Import `getImgMetadata` from `openimg/bun` and pass in a Readable stream (like `ReadStream`), a ReadableStream, or image Buffer. The function will return the width, height, and format of the image.
284
289
285
290
Example using a Readable stream:
286
291
@@ -289,8 +294,19 @@ import { getImgMetadata } from "openimg/bun";
Copy file name to clipboardexpand all lines: docs/api/node.md
+32-16
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# openimg/node
2
2
3
-
openimg/node (Open Image Node) provides a HTTP request handler function to optimize images using sharp, using Node-compatible APIs for Bun, Deno, and Node.js. It also provides utilities for generating low quality image placeholders and retrieving image metadata.
3
+
openimg/node (Open Image Node) provides a HTTP request handler function to optimize images with [sharp](https://sharp.pixelplumbing.com), using Node-compatible APIs for Bun, Deno, and Node.js. It also provides utilities for generating low quality image placeholders and retrieving image metadata.
4
4
5
5
## Features
6
6
@@ -16,19 +16,13 @@ The `openimg/bun` and `openimg/node` request handlers utilize the Web Fetch API'
16
16
17
17
## Installation
18
18
19
-
The code is available via `openimg/node` and `openimg-node`. For most use cases, you probably want to install `openimg`:
19
+
The code is available via `openimg/node`:
20
20
21
21
```bash
22
22
npm i sharp openimg
23
23
```
24
24
25
-
However, if you only want to use the server-side utilities for Node, you can also install `openimg-node`:
26
-
27
-
```bash
28
-
npm i sharp openimg-node
29
-
```
30
-
31
-
openimg package uses [sharp](https://sharp.pixelplumbing.com) and can only be used in environments that can run sharp (and [libvips](https://github.com/libvips/libvips)).
25
+
Note, openimg uses [sharp](https://sharp.pixelplumbing.com) and can only be used in environments that can run sharp (and [libvips](https://github.com/libvips/libvips)).
Import `getImgPlaceholder` from `openimg/node` and pass in a Readable stream (like `ReadStream`) or image Buffer. The function will return a low quality image placeholder as a base64-encoded string using [thumbhash](https://github.com/evanw/thumbhash). The generated string can be stored in a database or inlined in your client bundle as a placeholder until the full image is loaded.
255
+
Import `getImgPlaceholder` from `openimg/node` and pass in a Readable stream (like `ReadStream`), a ReadableStream, or image Buffer. The function will return a low quality image placeholder as a base64-encoded string using [thumbhash](https://github.com/evanw/thumbhash). The generated string can be stored in a database or inlined in your client bundle as a placeholder until the full image is loaded.
Import `getImgMetadata` from `openimg/node` and pass in a Readable stream (like `ReadStream`) or image Buffer. The function will return the width, height, and format of the image.
292
+
Import `getImgMetadata` from `openimg/node` and pass in a Readable stream (like `ReadStream`), a ReadableStream, or image Buffer. The function will return the width, height, and format of the image.
288
293
289
294
Example using a Readable stream:
290
295
@@ -293,8 +298,19 @@ import { getImgMetadata } from "openimg/node";
Copy file name to clipboardexpand all lines: docs/api/react.md
+2-8
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# openimg/react
2
2
3
-
openimg-react (Open Image React) provides an `Image` component (aliased as `Img`) for querying optimized images from an image optimization endpoint (e.g., openimg/node) and a context provider `OpenImgContextProvider` for global configuration options. The `Image` component renders an HTML picture element utilizing modern HTML attributes and best practices.
3
+
openimg/react (Open Image React) provides an `Image` component (aliased as `Img`) for querying optimized images from an image optimization endpoint (e.g., openimg/node or openimg/bun) and a context provider `OpenImgContextProvider` for global configuration options. The `Image` component renders an HTML picture element utilizing modern HTML attributes and best practices.
4
4
5
5
## Features
6
6
@@ -14,20 +14,14 @@ openimg-react (Open Image React) provides an `Image` component (aliased as `Img`
14
14
15
15
## Installation
16
16
17
-
The code is available via `openimg/react` and `openimg-react`. For most use cases, you probably want to install `openimg`:
17
+
The code is available via `openimg/react`:
18
18
19
19
```bash
20
20
npm i sharp openimg
21
21
```
22
22
23
23
Note, `sharp` is only needed if you want to use the server-side functionality.
24
24
25
-
If you only want to use the React utilities, you can also install `openimg-react` independently:
26
-
27
-
```bash
28
-
npm i openimg-react
29
-
```
30
-
31
25
## API
32
26
33
27
Import the `Img`/`Image` component from `openimg/react`:
0 commit comments