Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

450
Views
Estoy usando tinify en el nodo js. Wow, ¿podemos descargar el archivo suprimido usando nodejs?

Estoy usando npm install --save tinify luego cargando mis archivos de imagen usando nodejs pero necesito un archivo .zip comprimido en mi sistema.

Cuando estoy cargando mis archivos de imagen a través del navegador en https://tinypng.com después de cargar, muestra la opción de descarga que es perfecta. Pero, ¿cómo podemos hacer lo mismo a través de nodejs?

Aquí está mi código:

 var tinify = require("tinify"); tinify.key = "myRightApiCode"; var fs = require("fs"); fs.readFile("C:/Users/sourav/images/pgL_NA-10005_5.jpg", function(err, sourceData) { if (err) throw err; tinify.fromBuffer(sourceData).toBuffer(function(err, resultData) { if (err) throw err; // ... console.log(resultData); //need compressed file in my system }); });
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede usar el método de tinify que convierte y escribe la imagen comprimida a la vez:

 var sourceFile = tinify.fromFile("uncompressed.jpg"); sourceFile.toFile("compressed.jpg");

Alternativamente, en su método intente:

 var tinify = require("tinify"); tinify.key = "myRightApiCode"; var fs = require("fs"); fs.readFile("C:/Users/sourav/images/pgL_NA-10005_5.jpg", function(err, sourceData) { if (err) throw err; tinify.fromBuffer(sourceData).toBuffer(function(err, resultData) { if (err) throw err; fs.writeFile('C:/Users/sourav/images/optimized.jpg', resultData, function (err) { if (err) throw err; console.log('It\'s saved!'); }); }); });

Espero que esto resuelva tu consulta :)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!