drinks
areย on david ๐ป
ย
join us on slack
SSID: pixelbar
WW: 1337hacker
Pretty fly for a Wi-Fi:
ย
// hit return a few times
// first example; lets resize the image
const Jimp = require('jimp');
Jimp.read('in.jpg').then(image => {
image
.resize(100, 100)
.write('out.jpg');
});
// TIP: Also try passing Jimp.AUTO as one of the sizes
in.jpg
out.jpg
$ node index.js
in.jpg
out.jpg
out.jpg
With Jimp.AUTO
Squashed cat
Other operations
image.sepia()image.blur(n)image.invert()image.rotate(n)More in docs: https://www.npmjs.com/package/jimp
.sepia()
.invert()
.blur(10)
.rotate(180)
// second example; playing with colors
const Jimp = require('jimp');
Jimp.read('in.jpg').then(image => {
image
.color([
{apply: 'hue', params: [-90]}
])
.write('out.jpg');
});
https://www.npmjs.com/package/jimp#colour-manipulation
// second example; playing with colors
const Jimp = require('jimp');
Jimp.read('in.jpg').then(image => {
image
.color([
{apply: 'hue', params: [-90]},
// more modifiers can be applied here..
])
.write('out.jpg');
});
// third example; playing with text
const Jimp = require('jimp');
Jimp.read('in.jpg').then(image => {
Jimp.loadFont(Jimp.FONT_SANS_64_WHITE).then(font => {
image
.print(font, 10, 10, "They said there would be food", image.bitmap.width)
.write('out.jpg');
});
});
Have text located at top and bottom
Center the text in its container
Read text and image from arguments
Wrap this in an Express server so we can put memegenerator.net out of business
Figure out wether text should be black or white based on image colors
๐ http://expressjs.com
Further reading
https://www.npmjs.com/package/jimp
http://www.graphicsmagick.org
๐บ
Thanks!