import { copy, readFile, remove, rename } from 'fs-extra'
-import * as Jimp from 'jimp'
-import { v4 as uuidv4 } from 'uuid'
+import Jimp, { read } from 'jimp'
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 (
const inputBuffer = await readFile(path)
try {
- jimpInstance = await Jimp.read(inputBuffer)
+ jimpInstance = await read(inputBuffer)
} catch (err) {
logger.debug('Cannot read %s with jimp. Try to convert the image using ffmpeg first.', path, { err })
await convertWebPToJPG(path, newName)
await rename(newName, path)
- jimpInstance = await Jimp.read(path)
+ jimpInstance = await read(path)
}
await remove(destination)