fix: resize to fit for ico

issue #157
This commit is contained in:
C4illin 2024-10-04 23:55:39 +02:00
parent b5e8d82bfa
commit b4e53dbb8e

View file

@ -689,10 +689,18 @@ export async function convert(
fileType: string, fileType: string,
convertTo: string, convertTo: string,
targetPath: string, targetPath: string,
// biome-ignore lint/suspicious/noExplicitAny: <explanation> // eslint-disable-next-line @typescript-eslint/no-unused-vars
options?: any, _options?: unknown,
): Promise<string> { ): Promise<string> {
const command = `ffmpeg -i "${filePath}" "${targetPath}"`;
let extra = "";
if (convertTo === "ico") {
// make sure image is 256x256 or smaller
extra = `-filter:v "scale='min(256,iw)':min'(256,ih)':force_original_aspect_ratio=decrease"`
}
const command = `ffmpeg -i "${filePath}" ${extra} "${targetPath}"`;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
exec(command, (error, stdout, stderr) => { exec(command, (error, stdout, stderr) => {