auto-image-converter 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/image-converter.config.mjs +1 -0
- package/lib/converter.js +9 -1
- package/package.json +1 -1
package/lib/converter.js
CHANGED
|
@@ -5,15 +5,23 @@ import path from "node:path";
|
|
|
5
5
|
|
|
6
6
|
const supportedExt = [".png", ".jpg", ".jpeg"];
|
|
7
7
|
|
|
8
|
-
export async function convertImages({
|
|
8
|
+
export async function convertImages({
|
|
9
|
+
dir,
|
|
10
|
+
format,
|
|
11
|
+
quality,
|
|
12
|
+
recursive,
|
|
13
|
+
removeOriginal,
|
|
14
|
+
}) {
|
|
9
15
|
const pattern = recursive
|
|
10
16
|
? `${dir}/**/*.{png,jpg,jpeg}`
|
|
11
17
|
: `${dir}/*.{png,jpg,jpeg}`;
|
|
12
18
|
const files = await fg(pattern);
|
|
19
|
+
console.log("нашел файлы", files);
|
|
13
20
|
|
|
14
21
|
for (const file of files) {
|
|
15
22
|
const ext = path.extname(file);
|
|
16
23
|
const outFile = file.replace(ext, `.${format}`);
|
|
24
|
+
console.log(`Записываю файл: ${outFile}`);
|
|
17
25
|
|
|
18
26
|
const image = sharp(file);
|
|
19
27
|
const buffer =
|