1.0.4 • Published 7 years ago

base64-img v1.0.4

Weekly downloads
88,045
License
ISC
Repository
github
Last release
7 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-import@clue/gatsby-source-contentful@dottjt/mediareadejest-screenshot-base64-reporterjson-resume-to-vcardjoe-skeletonkcv-theme-mocha-responsive@bitbrother/stringersisloc-flexpickle-cafestringify-imgtw-oleh-gatsby-source-graphql@arcblock/forge-cli@bomijs/plugin-skeleton@bomijs/skeletonzax-compressyb-automatorzenika-formation-frameworkzfm20image2base64zombiecsswdio-fefanf-html-reporterwdio-fefanf-html-visreg-reporterwebuy-skeletonwebrdptshephang-botts-scraper@fourpost/gatsby-source-eventbrite@elsekoya/feathers-hooks@essilor-ditac/gatsby-source-contentful@livioo/vskeleton@ldaniel/base64-image-optimizer@luudjanssen/gatsby-source-contentful@martinleejones/gatsby-source-contentful@nearform/gatsby-source-contentful@entando/entando-bundle-cli@entando/entando-bundler@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-plugin@ordent/ramenboxmtl-tools-base64minifigmeshblu-img-2-textmeshblu-cammeshblu-connector-raspicammeshblu-raspicamnw-awesome-skeletonsecret-imgscraptcharocket-sledsasjs-cliself-controlnode-qq-ainbinode-weibo-simulation-apipic2spriteplaywright-cucumber-integrationperfx-a11y-plugin-esresolve-anticaptcharesolve-anticaptcha-report-incorrect-captchaqmyx-skeletonproject-controlrmi-downloaderqueer-iconsqs-ui-library-asset-inlinerqrqrqq-ai-sdkrmadobesisloc-flex-backendsite-2-pdfsheetify-inlinesl-chat-emojigp-posgoogle-search-image-downloadergithub-bitbar-countergrunt-img-base64img2url
1.0.4

7 years ago

1.0.3

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago