Skip to content

Instantly share code, notes, and snippets.

View vilellaj's full-sized avatar

Jonathan Vilella vilellaj

View GitHub Profile
@vilellaj
vilellaj / divideInEqualParts.js
Last active January 16, 2017 19:23
Given a number, divide it in equal parts respecting a limit, returning the value of a part.
divideInEqualParts(value, limit)
{
let result = (value / 2);
return (result > limit ? divideInEqualParts(result, limit) : result);
}
const fs = require('fs');
const sharp = require('sharp');
fs.readdirSync('./images').forEach(file => {
const buff = fs.readFileSync(`./images/${file}`);
sharp(buff).toFile('images/output.webp', (err, info) => {
if (err)
console.error(err);