Skip to content

Commit cef9b94

Browse files
committed
updating readme with browser information
1 parent 4bc3851 commit cef9b94

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
npm install heic-convert
1919
```
2020

21-
## Usage
21+
## Usage in NodeJS
2222

2323
Convert the main image in a HEIC to JPEG
2424

@@ -83,6 +83,18 @@ The work to convert an image is done when calling `image.convert()`, so if you o
8383

8484
_Note that while the converter returns a Promise and is overall asynchronous, a lot of work is still done synchronously, so you should consider using a worker thread in order to not block the main thread in highly concurrent production environments._
8585

86+
## Usage in the browser
87+
88+
While the NodeJS version of `heic-convert` may be compiled for use in the browser with something like `webpack`, [not all build tools necessarily like to compile all modules well](https://github.com/catdad-experiments/heic-convert/issues/29). However, what further complicates things is that this module uses pure-javascript implementations of a jpeg and png encoder. But the browser has its own native encoders! Let's just use those.
89+
90+
When compiling a client-side project, use:
91+
92+
```javascript
93+
const convert = require('heic-convert/browser');
94+
```
95+
96+
This is currently only supported in the main thread. Support for workers may be added in the future, but if you need it sooner, please create an issue or even a PR!
97+
8698
## Related
8799

88100
* [heic-cli](https://github.com/catdad-experiments/heic-cli) - convert heic/heif images to jpeg or png from the command line

0 commit comments

Comments
 (0)