From fac41683669a158a858733167e8d22014176ed04 Mon Sep 17 00:00:00 2001 From: EscapedGibbon Date: Tue, 25 Mar 2025 15:42:52 +0100 Subject: [PATCH 1/2] docs: update image loading via browser --- docs/Getting started.md | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/docs/Getting started.md b/docs/Getting started.md index 4af54ef0..e369530a 100644 --- a/docs/Getting started.md +++ b/docs/Getting started.md @@ -43,7 +43,7 @@ const parsedImage = readSync('../example.jpg'); ``` :::tip -Node.js can also load an image via `fetch` function. To get more information take a look at "Browser" part of this section. +Node.js can also load an image via `fetchURL`. To get more information take a look at "Browser" part of this section. ::: Once the image is loaded, it returns an instance of the `Image` class, so its methods can be applied. @@ -72,13 +72,12 @@ writeSync('../example.jpg', image); ### Loading your first image in browser -To load an image via browser, in order to instantiate it, you need to get an `arrayBuffer`. One of the ways : +To load an image via browser, in order to instantiate it, you may use `fetchURL` function: ```ts -const data = await fetch('https:://example.com/image.jpg'); -const bufferedData = await data.arrayBuffer(); -let image = decode(new DataView(bufferedData)); // image is ready for usage +import { fetchURL } from 'image-js'; +let image = await fetchURL('https:://example.com/image.jpg'); // image is ready for usage image = image.grey(); ``` @@ -129,10 +128,7 @@ In the `` part of your code insert your `image-js` script. For instance, h ```html From 73b135f26a7e3e793bbeefc722385818620e5511 Mon Sep 17 00:00:00 2001 From: EscapedGibbon Date: Tue, 25 Mar 2025 19:30:07 +0100 Subject: [PATCH 2/2] docs: add anchor link to "loading image in browser" --- docs/Getting started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Getting started.md b/docs/Getting started.md index e369530a..2f0121d1 100644 --- a/docs/Getting started.md +++ b/docs/Getting started.md @@ -43,7 +43,7 @@ const parsedImage = readSync('../example.jpg'); ``` :::tip -Node.js can also load an image via `fetchURL`. To get more information take a look at "Browser" part of this section. +Node.js can also load an image via `fetchURL`. To get more information take a look at ["Browser"](#loading-your-first-image-in-browser) part of this section. ::: Once the image is loaded, it returns an instance of the `Image` class, so its methods can be applied.