アニメーションを自動再生しないオプション (#4131)

* Refactor

* settings

* Media Proxy

* Replace API response
This commit is contained in:
MeiMei
2019-02-05 03:01:36 +09:00
committed by syuilo
parent 00b2d89f1a
commit f014b7ae0e
14 changed files with 404 additions and 170 deletions

View File

@@ -1,9 +1,9 @@
import * as fs from 'fs';
import * as tmp from 'tmp';
import * as sharp from 'sharp';
import { IImage, ConvertToJpeg } from './image-processor';
const ThumbnailGenerator = require('video-thumbnail-generator').default;
export async function GenerateVideoThumbnail(path: string): Promise<Buffer> {
export async function GenerateVideoThumbnail(path: string): Promise<IImage> {
const [outDir, cleanup] = await new Promise<[string, any]>((res, rej) => {
tmp.dir((e, path, cleanup) => {
if (e) return rej(e);
@@ -23,16 +23,7 @@ export async function GenerateVideoThumbnail(path: string): Promise<Buffer> {
const outPath = `${outDir}/output.png`;
const thumbnail = await sharp(outPath)
.resize(498, 280, {
fit: 'inside',
withoutEnlargement: true
})
.jpeg({
quality: 85,
progressive: true
})
.toBuffer();
const thumbnail = await ConvertToJpeg(outPath, 498, 280);
// cleanup
fs.unlinkSync(outPath);