Skip to content

Commit

Permalink
First commit!
Browse files Browse the repository at this point in the history
  • Loading branch information
cosimomeli committed Feb 4, 2017
0 parents commit 92c8e04
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# My test files
gulpfile.js
flags/
png-flags/

# Dependency directory
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules

#IDE files
.idea
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2017 Cosimo Meli

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Laravel-Elixir-Svg2png
>This is a simple wrapper around Laravel Elixir for [gulp-svg2png](https://github.com/akoenig/gulp-svg2png).
## Why?

As PHP GD library doesn't support SVG files, I had the need to convert all SVG files to PNG to use them.
With gulp-svg2png you can add the conversion to your build and deploy pipeline, so this is just its plugin for Laravel Elixir

## Getting Started
Install the module with [npm](https://npmjs.org):

```bash
$ npm install --save laravel-elixir-svg2png
```


And add it to your Elixir-enhanced Gulpfile, like so:

```javascript
var elixir = require('laravel-elixir');

require('laravel-elixir-svg2png');

elixir(function(mix) {
mix.svg2png('path/to/files/*.svg', 'destination-path');
});
```

## Arguments

### svg2png(src, dst, [width, height, opts])

`src`

The SVG images

`dst`

The destination path for PNG files

`width`

The width of destination files (defaults to SVG width)

`height`

The height of destination files (defaults to SVG height)

`opts`

```javascript
{
verbose: true, //Logs progress information
concurrency: 5 //Limit the amount of concurrent tasks processed at one time
}
```



## Example
This is an example of a Gulp file that runs svg2png to convert all my SVG flags :

```javascript
var elixir = require('laravel-elixir');
require('laravel-elixir-svg2png');

elixir(function(mix) {
mix.svgtopng('public/flags/*.svg', 'public/png-flags');
});
```

Adjust the concurrency number accordingly to your system resources!
28 changes: 28 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var gulp = require('gulp');
var Elixir = require('laravel-elixir');
var svg2png = require('gulp-svg2png');

var Task = Elixir.Task;

Elixir.extend('svg2png', function (src, dest, width, height, opts) {

opts = opts || {
verbose: true,
concurrency: 5
};

opts.options = {
width: width,
height: height
};

new Task('svg2png', function () {

console.log(opts)

return gulp.src(src)
.pipe(svg2png(opts.options, opts.verbose, opts.concurrency))
.pipe(gulp.dest(dest))
});

});
33 changes: 33 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "laravel-elixir-svg2png",
"version": "1.0.0",
"description": "Svg2png wrapper for Laravel Elixir.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "https://github.com/cosimomeli/laravel-elixir-svg2png.git"
},
"keywords": [
"laravel",
"elixir",
"svg2png",
"png",
"svg",
"gulp"
],
"author": "Cosimo Meli",
"license": "MIT",
"bugs": {
"url": "https://github.com/cosimomeli/laravel-elixir-svg2png/issues"
},
"homepage": "https://github.com/cosimomeli/laravel-elixir-svg2png",
"dependencies": {
"gulp-svg2png": "^2.0"
},
"peerDependencies": {
"laravel-elixir": ">=3.0"
}
}

0 comments on commit 92c8e04

Please sign in to comment.