How to use the node-base64-image.encode function in node-base64-image

To help you get started, we’ve selected a few node-base64-image examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GilbertGobbels / GAwesomeBot / Commands / Public / meme.js View on Github external
topText = topText || "";
		botText = botText || "";

		meme = meme.replace(/&/g, "").trim();

		// sometimes, empty string does not clear the default
		// "TOP TEXT" and "BOTTOM TEXT" from apimeme, so use space
		topText = topText.replace(/&/g, "").trim() || "+";
		botText = botText.replace(/&/g, "").trim() || "+";

		meme = encodeURI(meme);
		topText = encodeURI(topText);
		botText = encodeURI(botText);

		const uri = `http://apimeme.com/meme?meme=${meme}&top=${topText}&bottom=${botText}`;
		base64.encode(uri, { filename: "meme.jpg" }, (error, image) => {
			if(!error) {
				msg.channel.createMessage("", {
					file: image,
					name: "meme.jpg"
				});
			}
			else {
				msg.channel.createMessage(uri);
			}
		});
	};
github fuzhenn / node-svg2img / test / specs.js View on Github external
it('convert a svg with an image', function (done) {
        this.timeout(5000);
        var imageUrl = 'https://zh.wikipedia.org/static/images/project-logos/zhwiki-hans.png';
        Image64.encode(imageUrl, {}, function (err, base64) {
            var svgString = util.format('<svg height="258" width="540" version="1.1" xmlns="http://www.w3.org/2000/svg"><image href="%s" y="0" x="0" height="258" width="540"></image></svg>', 'data:image/png;base64,' + base64.toString('base64'));
            svg2img(svgString, function(error, data) {
                expect(error).not.to.be.ok();
                expect(Buffer.isBuffer(data)).to.be.ok();
                expect(data.length).to.be.above(0);
                done();
            });
        });
    });

node-base64-image

Download images from remote URLs and encode/decode them to base64

MIT
Latest version published 3 months ago

Package Health Score

72 / 100
Full package analysis