1.0.4 • Published 8 years ago

base64-img v1.0.4

Weekly downloads
88,045
License
ISC
Repository
github
Last release
8 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-1216tas-report-helpersvgtofontplusweb-skeleton-nodewdio-summary-reporterxl_base64stable-diffusion-clitestcafe-bdd-fwdtestcafe-cucumbervite-plugin-base64-importjest-screenshot-base64-reporterjson-resume-to-vcardjoe-skeletonkcv-theme-mocha-responsiveimg2urlimginjsidf-kivia-mka-back-for-frontimage-sequencerimage-cacheimage2base64jsimages2base64gulp-image2base64gulp-inline-srcgulp-base64-imggulp-base64-stylusgulp-convert-base64gulp-html5packergulp-h5epackergulp-h5packerhexo-helper-inline-svgmarkdown-it-plantuml-offlinemarkdown-html-genmarkdown-html-clilofter-awesome-skeletonlmmf-axelakspiderkuky.com@whalecloud/fishx-svgtofont@trptcolin/gatsby-source-contentful@thrillworksinc/gatsby-source-tw-oleh@tkz/gatsby-source-contentful@xorifelse/gatsby-source-eventbrite@yakies/cli@zohodesk/screenshot-test@zuoyanart/lens@zicusa/api-sv-infoackee-svg-converteranimate-embed-imagesaureus-covawesome-skeletonanyphotob-64archiviationapi-sv-info@clue/gatsby-source-contentful@bitbrother/stringersisloc-flexpickle-cafestringify-imgtw-oleh-gatsby-source-graphql@bomijs/plugin-skeleton@bomijs/skeletonzax-compressyb-automatorzenika-formation-frameworkzfm20image2base64zombiecsswdio-fefanf-html-reporterwdio-fefanf-html-visreg-reporterwebuy-skeletonwebrdptshephang-botts-scraper@livioo/vskeleton@ldaniel/base64-image-optimizer@nearform/gatsby-source-contentful@kanikarp/react-scripts@kanikarphan/react-scripts@proyecto-didi/didi-ssi-issuer-module-functional-test@proyecto-didi/didi-ssi-semillas-web-functional-test@pintob/gatsby-source-contentful@packem/file-pluginmtl-tools-base64minifigmeshblu-img-2-textmeshblu-cammeshblu-connector-raspicammeshblu-raspicamnw-awesome-skeleton
1.0.4

8 years ago

1.0.3

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago