1.0.2 • Published 3 years ago

gulp-img2b64 v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

gulp-img2b64

This is a simple Gulp plugin to convert from an image file stream to base64.

Install

Install as a "devDependencies" in your project:

$ npm i -D gulp-img2b64

Usage

This is an example of gulpfile.js.

const gulp = require('gulp')
const b64 = require('gulp-img2b64')

const image = () => 
    src('src/img/*')
        .pipe(b64())
        .pipe(dest('public/img'))
  • Takes all compatible images (jpg, jpeg or png) from "./src/img" directory;
  • Convert to base64 (data URL);
  • Saves in "./public/img" with the original names changing the extension to ".b64".*

Chained

Use with another plugin for better image optimization:

const gulp = require('gulp')
const b64 = require('gulp-img2b64')
const imagemin = require('gulp-imagemin')

const image = () => 
    src('src/img/*')
        .pipe(imagemin())
        .pipe(b64())
        .pipe(dest('public/img'))

See how gulp-imagemin can help you.

License

MIT © Bill Rocha