简体   繁体   中英

How Can I change Image type with NodeJS?

I need to change my Image type after Uploading. I have tried with image_magick but failed.What is the best way to change a image type.

In my experience, the best ImageMagick alternative in node.js is sharp , based on libvips library.

A simple usage example (convert jpeg to png):

const sharp = require('sharp')
// [...]
sharp('input.jpg')
.rotate()
.toFile('output.png', (err, info) => {
  console.log(info)
})

Docs: http://sharp.dimens.io/en/stable/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM