How to use node-base64-image - 8 common examples

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 owenconti / livecodingtv-bot / utils / Assets.js View on Github external
static loadUrl( url, callback ) {
        // base64 encode the loaded image
		base64.base64encoder( url, {
			string: true
		}, function( err, image ) {
			if ( err ) {
				console.log(err);
				return;
			}

			if ( callback ) {
				callback( image );
			}
		} );
    }
github owenconti / livecodingtv-bot / utils / Assets.js View on Github external
try {
			// Check for a custom asset
			fs.statSync( filePath );
		} catch( e ) {
			try {
				// No custom assets exists, look in the core assets directory
				filePath = path.join( __dirname, '../setup/core/assets/', fileName );
				fs.statSync( filePath );
			} catch( e2 ) {
				console.warn(`[bot] Asset: ${filePath} not found!`);
				return;
			}
		}

		// base64 encode the loaded image
		base64.base64encoder( filePath, {
			localFile: true,
			string: true
		}, function( err, image ) {
			if ( err ) {
				console.log(err);
				return;
			}

			if ( callback ) {
				callback( image );
			}
		} );
	}
}
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();
            });
        });
    });
github rohansapre / cleanhood / Web / server / services / event.service.server.js View on Github external
function uploadImage(req, res) {
        var eid = req.body.eid;
        var image = req.body.eImage;
        eid = eid.replace(/['"]+/g, '');
        var imageName = eid;
        console.log(imageName);
        var imageBuffer = new Buffer(image, 'base64');
        var options = {
            filename: __dirname + '/../../public/uploads/' + imageName
        };
        base64.decode(imageBuffer, options, function (err, success) {
            if(err) {
                res.sendStatus(500).send(err);
            }
            else {
                console.log(success);
                var url = '/Web/public/uploads/' + imageName + '.jpg';
                EventModel
                    .updateInitialPicture(eid, url)
                    .then(function (event) {
                        res.json(url);
                    }, function (error) {
                        res.sendStatus(500).send(error);
                    });
            }
        });
    }
github mendix / generator-mendix / generators / app / templates / Gruntfile.js View on Github external
grunt.registerTask("generate-icon", function () {
        var iconPath = path.join(currentFolder, "/icon.png"),
            options = {localFile: true, string: true},
            done = this.async();

            grunt.log.writeln("Processing icon");

        if (!grunt.file.exists(iconPath) || !grunt.file.exists(WIDGET_XML)) {
            grunt.log.error("can\'t generate icon");
            return done();
        }

        base64.base64encoder(iconPath, options, function (err, image) {
            if (!err) {
                var xmlOld = grunt.file.read(WIDGET_XML);
                parser.parseString(xmlOld, function (err, result) {
                    if (!err) {
                        if (result && result.widget && result.widget.icon) {
                            result.widget.icon[0] = image;
                        }
                        var xmlString = builder.buildObject(result);
                        grunt.file.write(WIDGET_XML, xmlString);
                        done();
                    }
                });
            } else {
                grunt.log.error("can\'t generate icon");
                return done();
            }
github jimkang / godtributes / get-image-analysis.js View on Github external
function getImageAnalysis(opts, done) {
  var imageURL;

  if (opts) {
    imageURL = opts.imageURL;
  }

  base64.base64encoder(imageURL, encooderOpts, sb(analyzeImage, done));
}
github yinxin630 / fiora-backend / api / utils / qiniu.js View on Github external
return new Promise((resolve, reject) => {
            Base64Image.base64decoder(imageData, {filename: '.tmp/temp'}, (err, saved) => {
                if (err) {
                    return reject(false);
                }
                return resolve(true);
            })
        });
    },

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