@runnerpro/backend 1.6.28 → 1.6.30

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.
@@ -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 rotateOrientationImage(image);
42
+ image = yield rotateOrientationImage(image, file);
42
43
  image = yield image.resize(newWidth, newHeight);
43
44
  image = yield image.quality(quality);
44
45
  // @ts-ignore
@@ -57,8 +58,8 @@ const reduceSizeImage = (file, newWidth = 100, quality = 80) => __awaiter(void 0
57
58
  }
58
59
  });
59
60
  exports.reduceSizeImage = reduceSizeImage;
60
- const rotateOrientationImage = (image) => __awaiter(void 0, void 0, void 0, function* () {
61
- // const orientation = await exifr.orientation(image);
61
+ const rotateOrientationImage = (image, file) => __awaiter(void 0, void 0, void 0, function* () {
62
+ const orientation = yield exifr_1.default.orientation(file);
62
63
  // let rotate;
63
64
  // if ([7, 8].includes(orientation)) rotate = 90;
64
65
  // else if ([3].includes(orientation)) rotate = 180;
@@ -66,5 +67,4 @@ const rotateOrientationImage = (image) => __awaiter(void 0, void 0, void 0, func
66
67
  // if (rotate) image = await image.rotate(rotate);
67
68
  // return image;
68
69
  return image.rotate(90);
69
- return image;
70
70
  });
@@ -1 +1 @@
1
- {"version":3,"file":"reduceSizeImage.d.ts","sourceRoot":"","sources":["../../../../src/image/reduceSizeImage.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,eAAe,kEAqCpB,CAAC;AAeF,OAAO,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"reduceSizeImage.d.ts","sourceRoot":"","sources":["../../../../src/image/reduceSizeImage.ts"],"names":[],"mappings":"AAOA,QAAA,MAAM,eAAe,kEAqCpB,CAAC;AAcF,OAAO,EAAE,eAAe,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runnerpro/backend",
3
- "version": "1.6.28",
3
+ "version": "1.6.30",
4
4
  "description": "A collection of common backend functions",
5
5
  "exports": {
6
6
  ".": "./lib/cjs/index.js"