X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fimage-utils.ts;h=c76ed545bb2b2bdba91fe33183cd6d2567cfda4b;hb=095094872a61ae534c115135c0789a73c741d704;hp=6f6f8d4da379952698f2fee76e64f956d104d9e7;hpb=84531547bc0934a2abda586d539f7455b455d488;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/image-utils.ts b/server/helpers/image-utils.ts index 6f6f8d4da..c76ed545b 100644 --- a/server/helpers/image-utils.ts +++ b/server/helpers/image-utils.ts @@ -1,12 +1,12 @@ import { copy, readFile, remove, rename } from 'fs-extra' import * as Jimp from 'jimp' -import { extname } from 'path' -import { v4 as uuidv4 } from 'uuid' +import { getLowercaseExtension } from './core-utils' import { convertWebPToJPG, processGIF } from './ffmpeg-utils' import { logger } from './logger' +import { buildUUID } from './uuid' function generateImageFilename (extension = '.jpg') { - return uuidv4() + extension + return buildUUID() + extension } async function processImage ( @@ -15,7 +15,7 @@ async function processImage ( newSize: { width: number, height: number }, keepOriginal = false ) { - const extension = extname(path) + const extension = getLowercaseExtension(path) if (path === destination) { throw new Error('Jimp/FFmpeg needs an input path different that the output path.') @@ -61,7 +61,8 @@ async function jimpProcessor (path: string, destination: string, newSize: { widt await remove(destination) // Optimization if the source file has the appropriate size - if (await skipProcessing({ jimpInstance, newSize, imageBytes: inputBuffer.byteLength, inputExt, outputExt: extname(destination) })) { + const outputExt = getLowercaseExtension(destination) + if (skipProcessing({ jimpInstance, newSize, imageBytes: inputBuffer.byteLength, inputExt, outputExt })) { return copy(path, destination) }