mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 02:39:33 +02:00
Generate 600x600 and 1500x1500 avatars
This commit is contained in:
parent
fb2dc40858
commit
109e93c139
19 changed files with 83 additions and 33 deletions
|
@ -31,7 +31,7 @@ export async function processImage (options: {
|
|||
if (extension === '.gif') {
|
||||
await processGIF({ path, destination, newSize })
|
||||
} else {
|
||||
await jimpProcessor(path, destination, newSize, extension)
|
||||
await jimpProcessor({ path, destination, newSize, inputExt: extension })
|
||||
}
|
||||
|
||||
if (keepOriginal !== true) await remove(path)
|
||||
|
@ -56,7 +56,17 @@ export async function getImageSize (path: string) {
|
|||
// Private
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function jimpProcessor (path: string, destination: string, newSize: { width: number, height: number }, inputExt: string) {
|
||||
async function jimpProcessor (options: {
|
||||
path: string
|
||||
destination: string
|
||||
newSize: {
|
||||
width: number
|
||||
height: number
|
||||
}
|
||||
inputExt: string
|
||||
}) {
|
||||
const { path, destination, newSize, inputExt } = options
|
||||
|
||||
let sourceImage: Jimp
|
||||
const inputBuffer = await readFile(path)
|
||||
|
||||
|
@ -125,7 +135,7 @@ function skipProcessing (options: {
|
|||
const { width, height } = newSize
|
||||
|
||||
if (hasExif(sourceImage)) return false
|
||||
if (sourceImage.getWidth() > width || sourceImage.getHeight() > height) return false
|
||||
if (sourceImage.getWidth() !== width || sourceImage.getHeight() !== height) return false
|
||||
if (inputExt !== outputExt) return false
|
||||
|
||||
const kB = 1000
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue