Skip to content

Commit f2e388f

Browse files
authored
refactor: rework and simplify Getting started page (#142)
- Put system requirements at the top - Change slug to `getting-started` - Change to MDX since it uses React components. - Remove Vite tutorial - Proofread
1 parent 2092187 commit f2e388f

File tree

4 files changed

+111
-181
lines changed

4 files changed

+111
-181
lines changed

docs/Getting started.md

Lines changed: 0 additions & 178 deletions
This file was deleted.

docs/getting-started.mdx

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
---
2+
title: Getting started
3+
sidebar_position: 0
4+
---
5+
6+
import Tabs from '@theme/Tabs';
7+
import TabItem from '@theme/TabItem';
8+
9+
# Getting started
10+
11+
ImageJS is a versatile and powerful library written in TypeScript for image processing and analysis. It gives a user a comprehensive set of tools and algorithms for manipulating, enhancing, and understanding images not only within Node.js but also across all popular browsers.
12+
13+
## System requirements
14+
15+
ImageJS is a modern library and does not actively support outdated runtimes.
16+
One of the following is required:
17+
18+
- An officially supported version of [Node.js](https://nodejs.org/en/download).
19+
- A modern and up-to-date web browser.
20+
21+
## Installation
22+
23+
Installation of ImageJS is straight-forward. Use the terminal to install the package:
24+
25+
<Tabs>
26+
<TabItem value="npm" label="npm" default>
27+
28+
```
29+
npm install image-js
30+
```
31+
32+
</TabItem>
33+
<TabItem value="yarn" label="yarn">
34+
35+
```
36+
yarn add image-js
37+
```
38+
39+
</TabItem>
40+
</Tabs>
41+
42+
## Loading your first image
43+
44+
There are two ways of loading an image to process it, depending on the way the user is operating:
45+
46+
### Loading and saving an image from Node.js
47+
48+
Local loading uses the `readSync` or `read` function with a filepath:
49+
50+
```ts
51+
import { read, readSync } from 'image-js';
52+
53+
const parsedImage = readSync('example.jpg');
54+
const parsedImageAsync = await read('example.jpg');
55+
```
56+
57+
:::tip
58+
Node.js can also load an image via `fetchURL`. To get more information, take a look at the next section.
59+
:::
60+
61+
Once the image is loaded, it returns an instance of the `Image` class, so its methods can be applied.
62+
63+
```ts
64+
const invertedImage = parsedImage.invert();
65+
```
66+
67+
To save an image use `writeSync` or `write` function:
68+
69+
```ts
70+
import { writeSync, write } from 'image-js';
71+
72+
writeSync('out.png', image);
73+
await write('out.png', image);
74+
```
75+
76+
Image format is automatically identified based on the extension. In this case it's `'.png'` so the image is saved as a PNG file.
77+
78+
So, in the end you should get a code like this:
79+
80+
```ts
81+
import { readSync, writeSync } from 'image-js';
82+
83+
const parsedImage = readSync('example.jpg');
84+
const image = parsedImage.invert();
85+
writeSync('example.png', image);
86+
```
87+
88+
### Loading an image from a web browser
89+
90+
To load an image via a browser, you may use the `fetchURL` function:
91+
92+
```ts
93+
import { fetchURL } from 'image-js';
94+
95+
let image = await fetchURL('https:://example.com/image.jpg');
96+
image = image.grey();
97+
```
98+
99+
:::info
100+
To see more methods, visit the ["Features"](./Features/Features.md) category.
101+
:::
102+
103+
## What's next?
104+
105+
Now that you know how images are loaded and saved, you can deepen your understanding by going through the [Basics](./Basics) category and seeing how different basic elements of ImageJS work.
106+
You can also broaden your horizons by looking at available [Features](./Features).
107+
108+
If you want to see how ImageJS works in practice, we suggest you visit the [Tutorials](./Tutorials) segment and see for yourself its practical applications.

docusaurus.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ async function createConfig() {
126126
items: [
127127
{
128128
type: 'doc',
129-
docId: 'Getting started',
129+
docId: 'getting-started',
130130
position: 'left',
131131
label: 'Docs',
132132
},
@@ -146,7 +146,7 @@ async function createConfig() {
146146
items: [
147147
{
148148
label: 'Getting started',
149-
to: '/docs/Getting started',
149+
to: '/docs/getting-started',
150150
},
151151
{
152152
label: 'Basics',

src/pages/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function HomepageHeader() {
3232
<div className={styles.buttons}>
3333
<Link
3434
className="button button--secondary button--lg"
35-
to="docs/Getting started"
35+
to="docs/getting-started"
3636
>
3737
Let&apos;s get started
3838
</Link>

0 commit comments

Comments
 (0)