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

grunt-gm

v0.4.3

Published

Batch process your images with gm.

Downloads

464

Readme

grunt-gm v0.4.3

Batch process your images with gm.

Getting Started

This plugin requires Grunt ~0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-gm --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-gm');

Overview

At the moment the task is pretty much just a simple grunt wrapper to gm.

Before start, please verify your GraphicsMagick or ImageMagick installation by running convert -vsersion.

If the task ran into error Fatal error: Maximum call stack size exceeded, it's probably because the files array is too long. To resolve this, try:

  • Run grunt with custom stack size node --stack-size=9999 node_modules/grunt-cli/bin/grunt gm
  • Check default by node --v8-options | grep -B0 -A1 stack_size

If your are on OSX, and the task ended with:

dyld: Library not loaded: /usr/local/lib/libfreetype.6.dylib
  Referenced from: /usr/local/bin/gm
  Reason: image not found

try brew unlink freetype && brew link freetype

The Task

See basic usages.

grunt.initConfig({
  gm: {
    test: {
      options: {
        // default: false, check if dest file exists and size > 0
        skipExisting: false,
        // default: false
        stopOnError: false,
        // task options will also be passed to arg callback
        yourcustomopt: {
          'test/gruntjs.png': '"JavaScript Task Runner"',
          'test/nodejs.png': '"JavaScript Runtime"'
        }
      },
      files: [
        {
          cwd: 'test',
          dest: 'test/out',
          expand: true,
          filter: 'isFile',
          src: ['**/*', '!**/out/*', '!{film,sample}.png'],
          options: {
            skipExisting: true,
            stopOnError: true
          }
          // image is passed as stream beteen tasks
          tasks: [
            {
              // resize and watermark
              resize: [200],
              command: ['composite'],
              in: ['test/sample.png']
            }, {
              // extent and center the image with padding arund it
              gravity: ['Center'],
              extent: [400, 360]
            }, {
              // frame it
              command: ['composite'],
              in: ['test/film.png']
            }, {
              // watermark text
              gravity: ['North'],
              font: ['arial', 30],
              draw: [
                'skewX', -13,
                // function in arg list will be called with current file object
                'fill', '#999', 'text', 2, 67, function (f) {return f.options.yourcustomopt[f.src[0]]},
                'fill', '#000', 'text', 0, 65, function (f) {return f.options.yourcustomopt[f.src[0]]}
              ]
            }
          ]
        }
      ]
    }
  }
});

Original|After Task #1|After Task #2|After Task #3|After Task #4 :------:|:---------------------:|:---------------------:|:---------------------:|:---------------------: gruntjs|gruntjs|gruntjs|gruntjs|gruntjs gruntjs|nodejs|nodejs|nodejs|nodejs

  • Options precedence:
    1. CLI, eg. --skipExising
    • File, eg. files:[{options:{skipExising:true}}]
    • Task, eg. gm:{task1:{options:{skipExising:true}}
  • Task will traverse the file list and execute gm tasks one by one, top down
  • Grunt with --verbose flag to print out corresponding gm argument list

TODO

Release History

  • 2014-10-03   v0.4.3   Add js build, update log dump
  • 2014-08-11   v0.4.1   Rebuild broken release
  • 2014-08-08   v0.4.0   Support function in task argument list
  • 2014-07-30   v0.3.0   Support multiple gm tasks
  • 2014-07-29   v0.2.1   Reimplement the task
  • 2014-07-28   v0.2.0   Add options skipExisting and stopOnError
  • 2014-07-27   v0.1.2   Temp fix require
  • 2014-07-27   v0.1.1   Fix log dump and mkdir -p dest if not exists
  • 2014-07-27   v0.1.0   Initial release