How to use the node-base64-image.base64encoder 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 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 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));
}

node-base64-image

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

MIT
Latest version published 9 months ago

Package Health Score

62 / 100
Full package analysis