gulp-img64-2
v0.0.8
Published
this is an upgraded version of gulp-img64-2
Downloads
8
Maintainers
Readme
gulp-img64-2
Convert and replace image-files within your DOM/HTML to base64-encoded data.
Example
gulpfile.js
var gulp = require('gulp');
var img64 = require('gulp-img64-2');
gulp.task('default', function () {
gulp.src('index.html')
.pipe(img64())
.pipe(gulp.dest('path'));
});
gulpfile.js option
maxWeightResource : default 10240
// maxWeightResource: a img size must less than maxWeightResource
var gulp = require('gulp');
var img64 = require('gulp-img64-2');
gulp.task('default', function () {
gulp.src('index.html')
.pipe(img64({
maxWeightResource: 4000
}))
.pipe(gulp.dest('path'));
});
maxAllWeightResource : default unlimited
// maxAllWeightResource: all the selected images size must less than maxAllWeightResource
var gulp = require('gulp');
var img64 = require('gulp-img64-2');
gulp.task('default', function () {
gulp.src('index.html')
.pipe(img64({
maxAllWeightResource: 4000
}))
.pipe(gulp.dest('path'));
});
startWeightResource : default 0
// startWeightResource: It must use with maxAllWeightResource, so all the selected images size must less than (maxAllWeightResource - startWeightResource)
var gulp = require('gulp');
var img64 = require('gulp-img64-2');
gulp.task('default', function () {
gulp.src('index.html')
.pipe(img64({
startWeightResource: 1000,
maxAllWeightResource: 4000
}))
.pipe(gulp.dest('path'));
});
isMoreImg : default false
// isMoreImg: More images will be selected for use with smaller parameters maxAllWeightResource
var gulp = require('gulp');
var img64 = require('gulp-img64-2');
gulp.task('default', function () {
gulp.src('index.html')
.pipe(img64({
startWeightResource: 1000,
maxAllWeightResource: 4000,
isMoreImg: true
}))
.pipe(gulp.dest('path'));
});
index.html // Before...
<html>
<head>
</head>
<body>
<body>
<img src="small.png" alt="">
<img src="big.png" alt="">
...
path/index.html // ...after:
<html>
<head>
</head>
<body>
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA2ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBh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