Skip to content

Commit

Permalink
fix: Switched to Jimp
Browse files Browse the repository at this point in the history
  • Loading branch information
Jense5 committed Feb 26, 2017
1 parent c15a47e commit 357f18c
Show file tree
Hide file tree
Showing 3 changed files with 596 additions and 165 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"cz-conventional-changelog": "^2.0.0",
"fs-extra": "^2.0.0",
"is-url": "^1.2.2",
"sharp": "^0.17.2",
"jimp": "^0.2.27",
"web-capture": "^0.1.2",
"winston": "^2.3.0"
},
Expand Down
11 changes: 7 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// @flow

import path from 'path';
import Jimp from 'jimp';
import fse from 'fs-extra';
import isUrl from 'is-url';
import sharp from 'sharp';
import Promise from 'bluebird';
import capture from 'web-capture';
import { getProminentColors } from 'color-extract';
Expand All @@ -14,12 +14,15 @@ const CACHEB = path.resolve(__dirname, '5fba6621adbd97fec1d933874bf49e5b.png');

// Resizes the cache files.@
const resizeCache = () => new Promise((resolve, reject) => {
sharp(CACHEA).resize(100).png().toFile(CACHEB, (error, info) => {
if (error) { reject(error); }
if (!error) { resolve(info); }
Jimp.read(CACHEA).then((img) => {
img.resize(100, 100).write(CACHEB, (err) => {
if (err) { reject(err); }
resolve();
});
});
});


// Clears the cache.
const clearCache = () => {
fse.removeSync(CACHEA);
Expand Down
Loading

0 comments on commit 357f18c

Please sign in to comment.