npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

laravel-elixir-images

v2.0.0

Published

Laravel Elixir Images Extension

Downloads

5

Readme

Laravel Elixir Images

This Laravel Elixir extension makes resizing and optimizing images a breeze. It depends on gulp-responsive, which depends on sharp. Please make sure sharp is installed before attempting to install this extension.

Usage

Use it like this:

gulp images

The --production flag will engage image optimization in addition to resizing. Works with gulp watch, too.

Installation

First, pull in the extension through NPM.

npm install --save laravel-elixir-images

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

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

require('laravel-elixir-images');

elixir(function(mix) {
   mix.images(null);
});

That's it! You're all set to go!

Usage

Assuming you write...

elixir(function(mix) {
    mix.images(null);
});

...this will compile images in resources/assets/images to public/img.

If you'd like to set a different output directory, you may pass a second argument to the images() method, like so:

mix.images(null, 'public/images')

Finally, if you want to override the images plugin options, you may pass an object as the third argument.

mix.images(null, null, {});

// See options at:
//  https://github.com/mrcsmcln/laravel-elixir-images/blob/master/index.js#L31
//  https://github.com/mahnunchik/gulp-responsive
//  https://www.npmjs.com/browse/keyword/imageminplugin

Sizes

You can specify different size settings like so:

mix.images('image.jpg', null, {
    sizes: [[], [1920], [1280, 720], [640, 480, 'west']]
})

The above code will generate four sizes of the original image.jpg:

  1. image.jpg, optimized-only
  2. image-1920.jpg, optimized and resized to 1920w
  3. image-1280x720.jpg, optimized, resized, and cropped to 1280x720
  4. image-640x480.jpg, optimized, resized, and cropped to 640x480, with a western crop gravity

Optimizers

You can use different optimizers instead of the default (lossless) ones:

mix.images('image.jpg', null, {
    optimizers: {
        jpg: require('imagemin-jpegoptim')
    }
})

It's probably recommended that you use lossy optimizers; lossless ones are included for the sake of the POLA. Find more optimizers here.

Extensions

You can change the options of the various image optimizers like so:

mix.images('image.jpg', null, {
    extensions: {
        jpg: {
            progressive: true,
            max: 50
        }
    }
})

WebP

You can turn off WebP output with the following option:

mix.images(null, null, {
    webp: false
})