@runnerpro/backend 1.6.26 → 1.6.27
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.
|
@@ -278,13 +278,18 @@ const resizeImage = (data, filePath, mimetype) => __awaiter(void 0, void 0, void
|
|
|
278
278
|
return rotateOrientationImage(data, image, null, mimetype);
|
|
279
279
|
});
|
|
280
280
|
const rotateOrientationImage = (data, filePath, image = null, mimetype) => __awaiter(void 0, void 0, void 0, function* () {
|
|
281
|
+
if (mimetype.includes('webp'))
|
|
282
|
+
return data;
|
|
281
283
|
if (!image)
|
|
282
284
|
image = yield jimp_1.default.read(filePath);
|
|
283
285
|
const orientation = yield exifr_1.default.orientation(data);
|
|
284
|
-
let rotate
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
let rotate;
|
|
287
|
+
if ([7, 8].includes(orientation))
|
|
288
|
+
rotate = 90;
|
|
289
|
+
else if ([3].includes(orientation))
|
|
290
|
+
rotate = 180;
|
|
291
|
+
else if ([5, 8].includes(orientation))
|
|
292
|
+
rotate = -90;
|
|
288
293
|
if (rotate)
|
|
289
294
|
image = yield image.rotate(rotate);
|
|
290
295
|
return image.getBufferAsync(jimp_1.default.MIME_JPEG);
|
|
@@ -18,6 +18,7 @@ const jimp_1 = __importDefault(require("jimp"));
|
|
|
18
18
|
const fs_1 = __importDefault(require("fs"));
|
|
19
19
|
const uuid_1 = require("uuid");
|
|
20
20
|
const path_1 = __importDefault(require("path"));
|
|
21
|
+
const exifr_1 = __importDefault(require("exifr"));
|
|
21
22
|
const reduceSizeImage = (file, newWidth = 100, quality = 80) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
23
|
try {
|
|
23
24
|
let filePath;
|
|
@@ -38,7 +39,7 @@ const reduceSizeImage = (file, newWidth = 100, quality = 80) => __awaiter(void 0
|
|
|
38
39
|
const imageHeight = dimensions.height;
|
|
39
40
|
const newHeight = Math.round((imageHeight * newWidth) / imageWidth);
|
|
40
41
|
let image = yield jimp_1.default.read(filePath);
|
|
41
|
-
image = yield image
|
|
42
|
+
image = yield rotateOrientationImage(image);
|
|
42
43
|
image = yield image.resize(newWidth, newHeight);
|
|
43
44
|
image = yield image.quality(quality);
|
|
44
45
|
// @ts-ignore
|
|
@@ -57,3 +58,16 @@ const reduceSizeImage = (file, newWidth = 100, quality = 80) => __awaiter(void 0
|
|
|
57
58
|
}
|
|
58
59
|
});
|
|
59
60
|
exports.reduceSizeImage = reduceSizeImage;
|
|
61
|
+
const rotateOrientationImage = (image) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
+
const orientation = yield exifr_1.default.orientation(image);
|
|
63
|
+
let rotate;
|
|
64
|
+
if ([7, 8].includes(orientation))
|
|
65
|
+
rotate = 90;
|
|
66
|
+
else if ([3].includes(orientation))
|
|
67
|
+
rotate = 180;
|
|
68
|
+
else if ([5, 8].includes(orientation))
|
|
69
|
+
rotate = -90;
|
|
70
|
+
if (rotate)
|
|
71
|
+
image = yield image.rotate(rotate);
|
|
72
|
+
return image;
|
|
73
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAkBpD,CAAC;
|
|
1
|
+
{"version":3,"file":"conversation.d.ts","sourceRoot":"","sources":["../../../../../src/chat/api/conversation.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,iBAAiB,0BAA2B,GAAG,SAkBpD,CAAC;AA0SF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduceSizeImage.d.ts","sourceRoot":"","sources":["../../../../src/image/reduceSizeImage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reduceSizeImage.d.ts","sourceRoot":"","sources":["../../../../src/image/reduceSizeImage.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,eAAe,kEAqCpB,CAAC;AAaF,OAAO,EAAE,eAAe,EAAE,CAAC"}
|