Skip to content

Instantly share code, notes, and snippets.

@qkreltms
Last active January 22, 2019 17:36
Show Gist options
  • Select an option

  • Save qkreltms/667a0c54ef2a58c194e27da82bc19e81 to your computer and use it in GitHub Desktop.

Select an option

Save qkreltms/667a0c54ef2a58c194e27da82bc19e81 to your computer and use it in GitHub Desktop.
Generate Thumbnail Example
/*1. install GraphicsMagick on Your PC (I installed it on C:)
/*2. install gm pakcage npm i --save gm
/*3. install request npm i --save request
/*4. test this code
/*
/*
*/
const fs = require('fs'),
gm = require('gm').subClass({
imageMagick: true
})
const request = require('request')
const stream2 = gm(request('https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png'))
.thumbnail('50', '50', '!') //! means exact size
.stream()
stream2.on('data', function (chunk) {
chunks.push(chunk)
})
stream2.on('end', function () {
var result = Buffer.concat(chunks);
console.log('final result:', result.toString('base64'));
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment