Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/unic/gulp-svg-dimensions

Gulp plugin to parse SVGs and save their dimensions to the file object
https://github.com/unic/gulp-svg-dimensions

Last synced: about 2 months ago
JSON representation

Gulp plugin to parse SVGs and save their dimensions to the file object

Awesome Lists containing this project

README

        

# gulp-svg-dimensions

Uses [Cheerio](https://www.npmjs.com/package/cheerio) to parse SVGs and add their dimensions (integer values of ```width``` and ```height``` attributes) to the file object (```file.data.dimensions```).

## Usage

First, install `gulp-svg-dimensions` as a development dependency:

```shell
npm install --save-dev gulp-svg-dimensions@git+https://[email protected]/unic/gulp-svg-dimensions.git
```

Then, add it to your `gulpfile.js`:

```javascript
var svgDimensions = require('gulp-svg-dimensions');

gulp.task('icons', function(){
gulp.src(['app/icons/*.svg'])
.pipe(svgDimensions())
// Some other plugin making use of file.data.dimensions
// e.g. { x:100, y:200 }
.pipe(plugin())
.pipe(gulp.dest('dist/icons/'));
});
```