Last active
January 22, 2019 17:36
-
-
Save qkreltms/667a0c54ef2a58c194e27da82bc19e81 to your computer and use it in GitHub Desktop.
Generate Thumbnail Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*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