@ryuu-reinzz/haruka-lib 3.6.2 → 3.7.0
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.
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
async function imageToWebp(media) {
|
|
11
11
|
const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`);
|
|
12
12
|
const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.jpg`);
|
|
13
|
-
fs.writeFile(tmpFileIn, media);
|
|
13
|
+
await fs.writeFile(tmpFileIn, media);
|
|
14
14
|
|
|
15
15
|
await new Promise((resolve, reject) => {
|
|
16
16
|
ffmpeg(tmpFileIn)
|
|
@@ -26,9 +26,9 @@ async function imageToWebp(media) {
|
|
|
26
26
|
.save(tmpFileOut);
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
const buff = fs.readFile(tmpFileOut);
|
|
30
|
-
fs.unlink(tmpFileOut);
|
|
31
|
-
fs.unlink(tmpFileIn);
|
|
29
|
+
const buff = await fs.readFile(tmpFileOut);
|
|
30
|
+
await fs.unlink(tmpFileOut);
|
|
31
|
+
await fs.unlink(tmpFileIn);
|
|
32
32
|
return buff;
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ export async function stickerImg(media, metadata) {
|
|
|
36
36
|
const wMedia = await imageToWebp(media);
|
|
37
37
|
const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`);
|
|
38
38
|
const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`);
|
|
39
|
-
fs.writeFile(tmpFileIn, wMedia);
|
|
39
|
+
await fs.writeFile(tmpFileIn, wMedia);
|
|
40
40
|
|
|
41
41
|
if (metadata.packname || metadata.author) {
|
|
42
42
|
const img = new webp.Image();
|
|
@@ -51,7 +51,7 @@ export async function stickerImg(media, metadata) {
|
|
|
51
51
|
const exif = Buffer.concat([exifAttr, jsonBuff]);
|
|
52
52
|
exif.writeUIntLE(jsonBuff.length, 14, 4);
|
|
53
53
|
await img.load(tmpFileIn);
|
|
54
|
-
fs.unlink(tmpFileIn);
|
|
54
|
+
await fs.unlink(tmpFileIn);
|
|
55
55
|
img.exif = exif;
|
|
56
56
|
await img.save(tmpFileOut);
|
|
57
57
|
return tmpFileOut;
|
|
@@ -18,7 +18,7 @@ async function videoToWebp(media) {
|
|
|
18
18
|
}
|
|
19
19
|
const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`);
|
|
20
20
|
const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.mp4`);
|
|
21
|
-
fs.writeFile(tmpFileIn, media);
|
|
21
|
+
await fs.writeFile(tmpFileIn, media);
|
|
22
22
|
|
|
23
23
|
await new Promise((resolve, reject) => {
|
|
24
24
|
ffmpeg(tmpFileIn)
|
|
@@ -45,9 +45,9 @@ async function videoToWebp(media) {
|
|
|
45
45
|
.save(tmpFileOut);
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
-
const buff = fs.readFile(tmpFileOut);
|
|
49
|
-
fs.unlink(tmpFileOut);
|
|
50
|
-
fs.unlink(tmpFileIn);
|
|
48
|
+
const buff = await fs.readFile(tmpFileOut);
|
|
49
|
+
await fs.unlink(tmpFileOut);
|
|
50
|
+
await fs.unlink(tmpFileIn);
|
|
51
51
|
return buff;
|
|
52
52
|
};
|
|
53
53
|
|
|
@@ -55,7 +55,7 @@ export async function stickerVid(media, metadata) {
|
|
|
55
55
|
const wMedia = await videoToWebp(media);
|
|
56
56
|
const tmpFileIn = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`);
|
|
57
57
|
const tmpFileOut = path.join(tmpdir(), `${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`);
|
|
58
|
-
fs.writeFile(tmpFileIn, wMedia);
|
|
58
|
+
await fs.writeFile(tmpFileIn, wMedia);
|
|
59
59
|
|
|
60
60
|
if (metadata.packname || metadata.author) {
|
|
61
61
|
const img = new webp.Image();
|
|
@@ -70,7 +70,7 @@ export async function stickerVid(media, metadata) {
|
|
|
70
70
|
const exif = Buffer.concat([exifAttr, jsonBuff]);
|
|
71
71
|
exif.writeUIntLE(jsonBuff.length, 14, 4);
|
|
72
72
|
await img.load(tmpFileIn);
|
|
73
|
-
fs.unlink(tmpFileIn);
|
|
73
|
+
await fs.unlink(tmpFileIn);
|
|
74
74
|
img.exif = exif;
|
|
75
75
|
await img.save(tmpFileOut);
|
|
76
76
|
return tmpFileOut;
|