@shibam/sticker-maker 1.0.8 → 1.0.9
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/dist/index.js +9 -10
- package/dist/lib/ToWebp.js +4 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -114,26 +114,25 @@ var Sticker = /** @class */ (function () {
|
|
|
114
114
|
*/
|
|
115
115
|
Sticker.prototype.toBuffer = function () {
|
|
116
116
|
return __awaiter(this, void 0, void 0, function () {
|
|
117
|
-
var buffer,
|
|
118
|
-
return __generator(this, function (
|
|
119
|
-
switch (
|
|
117
|
+
var buffer, MetaBuff, error_2;
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
switch (_a.label) {
|
|
120
120
|
case 0:
|
|
121
|
-
|
|
121
|
+
_a.trys.push([0, 4, , 5]);
|
|
122
122
|
return [4 /*yield*/, this.initialize()];
|
|
123
123
|
case 1:
|
|
124
|
-
|
|
124
|
+
_a.sent();
|
|
125
125
|
return [4 /*yield*/, (0, ToWebp_js_1.default)(this.buffer, this.metaInfo, this.extType, this.mimeType)];
|
|
126
126
|
case 2:
|
|
127
|
-
buffer =
|
|
128
|
-
_a = this;
|
|
127
|
+
buffer = _a.sent();
|
|
129
128
|
return [4 /*yield*/, new changeMetaInfo_js_1.default(this.metaInfo).add(buffer)];
|
|
130
129
|
case 3:
|
|
131
|
-
|
|
130
|
+
MetaBuff = _a.sent();
|
|
132
131
|
this.activeBuff = true;
|
|
133
|
-
this.outBuffer = this.extType !== 'gif' ?
|
|
132
|
+
this.outBuffer = this.extType !== 'gif' ? MetaBuff : buffer;
|
|
134
133
|
return [2 /*return*/, this.outBuffer];
|
|
135
134
|
case 4:
|
|
136
|
-
error_2 =
|
|
135
|
+
error_2 = _a.sent();
|
|
137
136
|
this.activeBuff = false;
|
|
138
137
|
throw new Error("Conversion to buffer failed: ".concat(error_2));
|
|
139
138
|
case 5: return [2 /*return*/];
|
package/dist/lib/ToWebp.js
CHANGED
|
@@ -72,7 +72,7 @@ var ToWebp = function (buffer, metaInfo, mimeExt, mimeType) { return __awaiter(v
|
|
|
72
72
|
case 2:
|
|
73
73
|
// Write input buffer to temporary file
|
|
74
74
|
_d.sent();
|
|
75
|
-
if (!(mimeType === null || mimeType === void 0 ? void 0 : mimeType.includes('video'))) return [3 /*break*/, 4];
|
|
75
|
+
if (!((mimeType === null || mimeType === void 0 ? void 0 : mimeType.includes('video')) || (mimeType === null || mimeType === void 0 ? void 0 : mimeType.includes('webp')))) return [3 /*break*/, 4];
|
|
76
76
|
return [4 /*yield*/, (0, toGif_js_1.default)(inputPath)];
|
|
77
77
|
case 3:
|
|
78
78
|
_a = _d.sent();
|
|
@@ -96,7 +96,7 @@ var ToWebp = function (buffer, metaInfo, mimeExt, mimeType) { return __awaiter(v
|
|
|
96
96
|
? "-filter_complex \"color=".concat(metaInfo.background, " [c]; [c][0]scale2ref[cs][0s];[cs][0s]overlay=shortest=1, unsharp=3:3:0.5").concat(metaInfo.type === StickerTypes_js_1.StickerTypes.CIRCLE ||
|
|
97
97
|
metaInfo.type === StickerTypes_js_1.StickerTypes.SQUARE ||
|
|
98
98
|
metaInfo.type === StickerTypes_js_1.StickerTypes.FIT
|
|
99
|
-
? ", ".concat(metaInfo.type.
|
|
99
|
+
? ", ".concat(metaInfo.type.replaceAll(/-vf/g, '').replaceAll(/"/g, '').replace('-filter_complex', '').trim())
|
|
100
100
|
: '', "\"")
|
|
101
101
|
: '-pix_fmt yuva420p',
|
|
102
102
|
(mimeExt === null || mimeExt === void 0 ? void 0 : mimeExt.includes('gif')) || (mimeType === null || mimeType === void 0 ? void 0 : mimeType.includes('video'))
|
|
@@ -106,10 +106,7 @@ var ToWebp = function (buffer, metaInfo, mimeExt, mimeType) { return __awaiter(v
|
|
|
106
106
|
'-lag-in-frames 0',
|
|
107
107
|
'-preset default',
|
|
108
108
|
'-t 10',
|
|
109
|
-
'-r 15',
|
|
110
109
|
'-loop 0',
|
|
111
|
-
'-metadata:s:v:0 alpha_mode="1"',
|
|
112
|
-
'-lossless 1'
|
|
113
110
|
].join(' ')
|
|
114
111
|
: '-c:v libwebp',
|
|
115
112
|
'-q:v',
|
|
@@ -117,11 +114,13 @@ var ToWebp = function (buffer, metaInfo, mimeExt, mimeType) { return __awaiter(v
|
|
|
117
114
|
'-y',
|
|
118
115
|
outputPath
|
|
119
116
|
];
|
|
117
|
+
//console.log(args.join(" "))
|
|
120
118
|
// Execute ffmpeg command with constructed arguments
|
|
121
119
|
return [4 /*yield*/, execAsync("ffmpeg ".concat(args.join(' ')))
|
|
122
120
|
// Read converted WebP file back into a buffer
|
|
123
121
|
];
|
|
124
122
|
case 6:
|
|
123
|
+
//console.log(args.join(" "))
|
|
125
124
|
// Execute ffmpeg command with constructed arguments
|
|
126
125
|
_d.sent();
|
|
127
126
|
return [4 /*yield*/, (0, promises_1.readFile)(outputPath)];
|