2.2.0 • Published 4 years ago

image-to-base64 v2.2.0

Weekly downloads
25,185
License
MIT
Repository
github
Last release
4 years ago

image-to-base64

Generate a base64 code from an image through a URL or a path.

NPM Version NPM Downloads Build Status Tests Codacy Badge

About

It's a thing you can use in many situations, for example you can just save the base64 string in your database and increment it in the front-end with the <img> tag in HTML.

Getting Started

Installation:

npm i -S image-to-base64

Code Example:

const imageToBase64 = require('image-to-base64');
//or
//import imageToBase64 from 'image-to-base64/browser';

imageToBase64("path/to/file.jpg") // Path to the image
    .then(
        (response) => {
            console.log(response); // "cGF0aC90by9maWxlLmpwZw=="
        }
    )
    .catch(
        (error) => {
            console.log(error); // Logs an error if there was one
        }
    )

Remember that you can also use an image URL as a parameter.

Code Example:

imageToBase64("https://whatever-image/") // Image URL
    .then(
        (response) => {
            console.log(response); // "iVBORw0KGgoAAAANSwCAIA..."
        }
    )
    .catch(
        (error) => {
            console.log(error); // Logs an error if there was one
        }
    )

Browser Usage

You can import image-to-base64 using the <script> tag in HTML.

Code Example:

<script src="node_modules/image-to-base64/image-to-base64.min.js"></script>

Now you can use the module normally as in the JS examples above, but you can only use a URL and not a path.

LICENSE

MIT © 2017 RENAN.BASTOS

virtuellesburgerburothumbnails-creatorthumbnails-creator-pdfperfecto-ai-reportsbot_megabotwa_zap2@sejazipper/magento2-apiyyhelpzipper-magento-integration@everything-registry/sub-chunk-1903banana-dev-typedtarjouspalvelu.jssynapseapiwabusejswppbotwhatsapp_engine_jsxln-lgsc-filetobase64xlvg-utilswshoto-img-words-checkteamcothumbnail-creator-pdfvscode-html-to-docx@bnsights-test/test-utilities@bnsights/bbsf-utilities@rpii/wdio-html-reporterjsonresume-theme-mocha-responsivekeytrovekenskens.jsanya-mdrejst-mentalsword-testing01schenimsome-images-to-pdftruffle-tstorch-ly-cli@anthonyjdella/jsonresume-theme-anthonyjdella-mocha-responsive@appworks/material-engine@adminworks/material-engine@banana-dev/banana-dev@alternative-path/report-portal-playwright-reporter@btu-hive/base-app-backend-v3@adalat-ai/html-to-docxwdio-html-nice-reporter@fforres/pokemon-local-database@fe-components/excel-it@felwine/sdk@editframe/editframe-js@focusworkstemp/material-engine@iceworks/material-engine@infinitebrahmanuniverse/nolb-image-@legend80s/image-to-base64@mark-beeby/html-to-docx@neurapartner/html-to-docx-typescript@evolvus/evolvus-charges-generate-pdf@notifiles/sdk@nudgelabs/html-to-docx-nudgelabsmtg-card-analyzer-sdkmqq-reader-iconsmyhealthcaremyhealthcarehismighty-batchovt-fepdf-thumbnail-creatorrejst-mentalsword-testing00rejst-mentalsword-testing02rejst-mentalsword-testing03promet-iconsnftanknode-taggunpermawebpretty-qrrich-to-wordreact-native-tabler-iconssolapihtml-to-docx-nudgelabshtml-to-docx-plushtml-to-docx-tshtml-to-docx-updatehtml-to-docx-updateshtml-to-docxhtml-to-docx-cehtml-to-docx-dinnyehtml-to-docx-hubhtml-to-gutenberginstagram-without-api-nodeinstagram-get-postsinstant-image-hostmdpdfmakemdpdfmake-with-table-support@zalastax/nolb-image-ace-spades@xlsft/html-docx-v2@turbodocx/html-to-docx@warp-works/warpjs@w4b/mainanimeflvbase64-convertorazu-pck-orm-tsazu-pck-tscoolsms-node-sdk
2.2.0

4 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.3.5

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago