node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »



What is it ?

Graphic is an interface for Graphic library. The idea, that exists in others languages, is to have interface available for diferents graphics libraries : don't change your code, just the library.

How to use

For the prototype, I have used Jimp as library. It's simple, without package to install into OS.

    // test.js 
    var test = function (processorName, processor) {
        // After Processor instanciation, the base contract is the same 
        // for all libraries (jimp, ImageMagick, GD, etc) 
        var image;
 + '/test.jpg')
        .then(img => (image = img).getSize())
        .then(size => {
            console.log(`The picture does ${size.getWidth()} x ${size.getHeight()} with ${processorName}`)
            return image.crop(new Zone(new Point(25, 25), size.decrease(50)));
        .then(image => image.saveJPEG(__dirname + '/test_' + processorName + '.jpg', 70))
        .then(image => console.log('Picture saved by ' + processorName))
    var JimpProcessor = require('../Jimp/Processor');
    test('Jimp', new JimpProcessor());
    // Tomorrow, you can change JimpProcessor for ImageMagickProcessor changing only the first 2 lines. 
    // And use the best processor for your situation : fast, features rich, etc : 
    var ImageJsProcessor = require('../ImageJs/Processor');
    test('ImageJs', new ImageJsProcessor());

Note that some ideas are from PHP library "Imagine".


If you are interested in this project, please star, follow the github project, email me or others contacts. Graphic is under developement, any minor version of 1.x can broke features. If the idea pleases to you, you can propose to participate !

Note that due to package transfer, graphic will start from version 1.x for development version and 2.x for stable version.