1.0.4 • Published 6 years ago

base64-img v1.0.4

Weekly downloads
88,045
License
ISC
Repository
github
Last release
6 years ago

base64-img

Convert img to base64, or convert base64 to img

var base64Img = require('base64-img');

install

npm install base64-img --save

test

mocha

API

.base64(filename, callback)

Convert image file to image base64 data

  • {string} filename required
    The image path
  • {function} callback(err, data) required
    Callback with image base64 data
base64Img.base64('path/demo.png', function(err, data) {})

.base64Sync(filename)

The api same as base64, but it's synchronous

var data = base64Img.base64Sync('path/demo.png');
var data2 = base64Img.base64Sync('path/demo.svg');

.requestBase64(url, callback)

  • {string} url required
  • {function} callback(err, res, body) required
    Callback with http request
var url = 'http://../demo.png';
base64Img.requestBase64(url, function(err, res, body) {
  
});

.img(data, destpath, name, callback)

Convert image base64 data to image

  • {string} data required
    Image base64 data
  • {string} destpath required
    Dest path, if the destpath is root, pass empty string
  • {string} name required
    The image's filename
  • {function} callback(err, filepath) required
base64Img.img('data:image/png;base64,...', 'dest', '1', function(err, filepath) {});

.imgSync(data, destpath, name)

The api same as img, but it's synchronous

var filepath = base64Img.imgSync('data:image/png;base64,...', '', '2');
marigold-buildbase64-image-phavlaa_erp_serviceimg-base64-clicov-aureushihfs_blhihfs_business_logic@bsgreenb/gatsby-source-contentful@cloudtype/presets@weblinuz/api@cloady/api@everything-registry/sub-chunk-1216yb-automatorwdio-fefanf-html-reporterwdio-fefanf-html-visreg-reporterwdio-summary-reporterwebuy-skeletonwebrdpweb-skeleton-nodetestcafe-bdd-fwdtestcafe-cucumberts-scrapertshephang-bottw-oleh-gatsby-source-graphql@entando/entando-bundle-cli@entando/entando-bundlervite-plugin-base64-importsvgtofontplustas-report-helperzombiecss@essilor-ditac/gatsby-source-contentfulzfm20image2base64resolve-anticaptcharesolve-anticaptcha-report-incorrect-captcharmadobermi-downloaderrocket-sledsecret-imgscraptchasasjs-clisheetify-inlineself-controlsite-2-pdfsl-chat-emojistringify-imgstable-diffusion-cli@luudjanssen/gatsby-source-contentful@packem/file-plugin@ordent/ramenboxxl_base64@elsekoya/feathers-hookszenika-formation-frameworkzax-compress@bitbrother/stringer@fourpost/gatsby-source-eventbrite@pintob/gatsby-source-contentful@proyecto-didi/didi-ssi-issuer-module-functional-test@proyecto-didi/didi-ssi-semillas-web-functional-test@nearform/gatsby-source-contentful@soyjak/utils@ldaniel/base64-image-optimizer@martinleejones/gatsby-source-contentful@livioo/vskeleton@smarterlabs/gatsby-source-cloudinary@tkz/gatsby-source-contentful@thrillworksinc/gatsby-source-tw-oleh@trptcolin/gatsby-source-contentful@kanikarp/react-scripts@kanikarphan/react-scriptsfe-robot-plugin-base64toimgfe-robot-plugin-baseimggatsby-source-tw-olehfuse-box-testfusebox-clifuseboxfsbxfroncubator-adminfroncubator-bridgegatsby-source-contentful-richtext-safegatsby-source-contentful-fastgatsby-source-eventbritegatsby-source-eventbrite-multipleorgsfz-screenshot-test@yakies/cli@whalecloud/fishx-svgtofont@zuoyanart/lens@xorifelse/gatsby-source-eventbriteflexport-gatsby-source-contentful@zohodesk/screenshot-test@zicusa/api-sv-infoface-mergeapi-sv-infoanyphotogithub-bitbar-counterb-64hexo-helper-inline-svg@clue/gatsby-source-contentfulcode_snippetjest-screenshot-base64-reporternode-weibo-simulation-api
1.0.4

6 years ago

1.0.3

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago