Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

182
Vistas
Siempre tengo un problema si la imagen ya está creada

Este proyecto cambia los tamaños de las imágenes este proyecto está usando una librería llamada sharp, pero al principio si la imagen es creada por primera vez no da problemas, pero siempre me muestra ese problema si ya fue creada. En el archivo imageProcessing.ts

 import { Request, Response } from "express"; import fs, { promises as fsPromises } from 'fs'; import resizingTheImage from "./resizingTheImage"; const imageProcessing = async(req: Request, res: Response, next: Function): Promise<void | string> => { const widthValue = <string>req.query.width; const heightValue = <string>req.query.height; const nameFileValue = <string>req.query.namefile; const outputDir = `../../images/imageOutput/${nameFileValue}${widthValue}_${heightValue}.jpg`; const makeDir = async (): Promise<void> => { await fsPromises.mkdir('./images/imageOutput'); }; const imageProcessing = async (): Promise<void> => { try { await resizingTheImage(widthValue, heightValue, nameFileValue); } catch { res.send('There is a problem with the image processing'); } }; if (fs.existsSync(outputDir)) { return outputDir; } else { makeDir(); await imageProcessing(); } next(); } export default imageProcessing;

Al cambiar el resizingTheImage.ts archivo TheImage.ts

 import sharp from "sharp"; const resizingTheImage = async (imageWidth: string, imageHeight: string, fileName: string): Promise<void> => { const imageDir: string = `./images/${fileName}.jpg`; const outputDir: string = `./images/imageOutput/${fileName}${imageWidth}_${imageHeight}.jpg`; if (isNaN(parseInt(imageWidth) && parseInt(imageHeight)) && fileName) { console.log("the inputs is Invalid") } else { await sharp(imageDir) .resize(parseInt(imageWidth), parseInt(imageHeight)) .toFile(outputDir); } } export default resizingTheImage;

por error

 [Error: EEXIST: file already exists, mkdir 'E:\Image Processing API\images\imageOutput'] { errno: -4075, code: 'EEXIST', syscall: 'mkdir', path: 'E:\\Image Processing API\\images\\imageOutput' }
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda