aboutsummaryrefslogtreecommitdiff
path: root/src/server/DashUploadUtils.ts
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-12-10 20:19:27 -0500
committerbobzel <zzzman@gmail.com>2023-12-10 20:19:27 -0500
commit380ee1acac1c0b7972d7d423cf804af146dc0edf (patch)
tree1d77244a600e6eb1fb6d56356b3ce01ca6add89d /src/server/DashUploadUtils.ts
parentb7b7105fac83ec11480204c5c7ac0ae6579774e1 (diff)
massive changes to use mobx 6 which means not accessing props directly in @computed functions.
Diffstat (limited to 'src/server/DashUploadUtils.ts')
-rw-r--r--src/server/DashUploadUtils.ts27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts
index 7765349ff..dd2a857d9 100644
--- a/src/server/DashUploadUtils.ts
+++ b/src/server/DashUploadUtils.ts
@@ -25,6 +25,7 @@ const ffmpeg = require('fluent-ffmpeg');
const fs = require('fs');
const requestImageSize = require('../client/util/request-image-size');
const md5File = require('md5-file');
+const autorotate = require('jpeg-autorotate');
export enum SizeSuffix {
Small = '_s',
@@ -604,17 +605,21 @@ export namespace DashUploadUtils {
sizes.filter(({ width }) => !width).map(({ suffix }) =>
new Promise<void>(res => createReadStream(sourcePath).pipe(createWriteStream(outputPath(suffix))).on('close', res))
)); // prettier-ignore
- return Jimp.read(sourcePath)
- .then(async img => {
- await Promise.all( sizes.filter(({ width }) => width) .map(({ width, suffix }) =>
- img = img.resize(width, Jimp.AUTO).write(outputPath(suffix))
- )); // prettier-ignore
- return writtenFiles;
- })
- .catch(e => {
- console.log('ERROR' + e);
- return writtenFiles;
- });
+
+ const fileIn = fs.readFileSync(sourcePath);
+ return autorotate.rotate(fileIn, { quality: 30 }).then(({ buffer }: { buffer: any }) =>
+ Jimp.read(buffer)
+ .then(async img => {
+ await Promise.all( sizes.filter(({ width }) => width) .map(({ width, suffix }) =>
+ img = img.resize(width, Jimp.AUTO).write(outputPath(suffix))
+ )); // prettier-ignore
+ return writtenFiles;
+ })
+ .catch(e => {
+ console.log('ERROR' + e);
+ return writtenFiles;
+ })
+ );
}
/**