import sharp from "sharp"
import path from "path"

const resizeImg = async (width: number, height: number, fileName: string): Promise<string> => {
    // output file for resized img
    let inputimgPath: string = path.resolve("images/full", `${fileName}.jpg`);
    let outputImg: string = path.resolve("images/thumb", `${fileName}.jpg`);
    await sharp(path.resolve(inputimgPath))
        .resize(width, height)
        .toFormat("jpeg")
        .jpeg({
            quality: 100,
            mozjpeg: true
        })
        .toFile(path.resolve(outputImg))
        
    return outputImg
}

export default resizeImg