Converts SVG images to PNG using Sharp
As PHP GD library doesn't support SVG files, I had the need to convert all SVG files to PNG to use them. With this plugin you can add the conversion to your build and deploy pipeline.
Install the module with npm:
$ npm install --save laravel-elixir-svg2png
And add it to your Elixir-enhanced Gulpfile, like so:
var elixir = require('laravel-elixir');
require('laravel-elixir-svg2png');
elixir(function(mix) {
mix.svg2png('path/to/files/*.svg', 'destination-path');
});
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)
This is an example of a Gulp file that runs svg2png to convert all my SVG flags :
var elixir = require('laravel-elixir');
require('laravel-elixir-svg2png');
elixir(function(mix) {
mix.svg2png('public/flags/*.svg', 'public/png-flags');
});