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
Download images with an url that contains `{i}` placeholder for the index, and specify the start and end index.
28
+
29
+
### Overwrite prevention
30
+
31
+
To prevent overwriting, ` (n)` will be appended to the name of the new file if the file with the same name already exists.
32
+
33
+
The number will be incremented until the file name is unique in the directory, starting from 1 (e.g. `image (1).jpg`, `image (2).jpg`, etc.).
34
+
35
+
Image with different extension will be considered as **different** file, so it will not be appended with ` (n)`. For example, `image.jpg` and `image.png` will not be considered as the same file.
36
+
37
+
> This feature will work for both single and bulk download.
38
+
10
39
## Prerequisites
11
40
12
-
- Node.js 18 or later
13
-
- npm 9 or later
41
+
- Node.js 20.9 or later
42
+
- npm 10 or later
14
43
15
44
## Installation
16
45
@@ -43,7 +72,7 @@ USAGE
43
72
PARAMETERS
44
73
url The URL of the image to download. Provide multiple URLs to download multiple images.
45
74
In increment mode, the URL must contain {i} placeholder for the index,
46
-
only one URL is allowed, and the 'end' flag is required.
75
+
only one URL is allowed, and the '--end' is required.
47
76
48
77
OPTIONS
49
78
-d, --dir=<path> The output directory. Default: current working directory
@@ -53,7 +82,7 @@ OPTIONS
53
82
-H, --header=<header> The header to send with the request. Can be used multiple times
console.error(`Failed to download ${url}: ${error.message}`);
165
+
},
166
+
});
167
+
168
+
console.log('Download completed');
122
169
```
123
170
124
171
## API
125
172
126
173
### imgdl(url, ?options)
127
174
175
+
Returns: `Promise<void>`
176
+
128
177
Download image(s) from the given URL(s).
129
178
130
179
#### `url`
@@ -172,7 +221,7 @@ The interval between each batch of requests in milliseconds when downloading mul
172
221
Type: `string`<br>
173
222
Default: `'image'`
174
223
175
-
The filename. If not specified, the original filename will be used. If the original filename is not available, 'image' will be used. <br>When downloading multiple images, `-index` will be appended to the end of the name (suffix). `index` will start from 1. For example: 'image-1'
224
+
The filename. If not specified, the original filename will be used. If the original filename is not available, 'image' will be used.
176
225
177
226
##### `maxRetry`
178
227
@@ -186,14 +235,14 @@ Set the maximum number of times to retry the request if it fails.
186
235
Type: `(image: Image) => void`<br>
187
236
Default: `undefined`
188
237
189
-
The callback function to be called when the image is successfully downloaded. Only available when downloading multiple images.
238
+
The callback function to be called when the image is successfully downloaded.
190
239
191
240
##### `onError`
192
241
193
242
Type: `(error: Error, url: string) => void`<br>
194
243
Default: `undefined`
195
244
196
-
The callback function to be called when the image fails to download. Only available when downloading multiple images.
245
+
The callback function to be called when the image fails to download.
@@ -238,4 +273,4 @@ Set timeout for each request in milliseconds.
238
273
239
274
Give a ⭐️ if this project helped you!
240
275
241
-
You can support this project by donating via [GitHub Sponsors](https://github.com/sponsors/fityannugroho), [Trakteer](https://trakteer.id/fityannugroho/tip), or [Saweria](https://saweria.co/fityannugroho).
276
+
Also please consider supporting this project with a **donation**. Your donation will help us maintain and develop this project and provide you with better support.
0 commit comments