gemini-testing / png-img

Lite libpng wrapper for node.js
MIT License
29 stars 13 forks source link

Addition of constructor with just image dimensions #33

Open pdr0663 opened 7 years ago

pdr0663 commented 7 years ago

Could we please have a constructor which receives width and height as arguments and returns a blank image?

Paul

j0tunn commented 7 years ago

Hi, I don't think its necessary. You can do it via some wrapper like:

function mkImg(width, height) {
    const blackPxl = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQImWNgYAAAAAMAAaCmo9QAAAAASUVORK5CYII=';
    const buff = new Buffer(blackPxl, 'base64');
    return new PngImg(buff).setSize(width, height);
}
pdr0663 commented 7 years ago

Not quite as elegant as:

var img = new png-img(width, height);

j0tunn commented 7 years ago

Agree, but png-img was designed for work with existing images. And I don't think such constructor will be added in near future