Search code examples
node.jsimagemagickgruntjsfavicon

Grunt.js - Grunt-favicons output


I have used Grunt for quite some time now and this is a first. For some strange reason I cannot get this new npm I'm trying to use to work. I ran npm install grunt-favicons --save-dev and that worked fine, I have ImageMagick installed and what not. I have the paths and what not set correctly and have grunted, and it seems to work fine. Just there are no files. I have checked folder permissions and everything. I'm just curious if some smart cookies out there know what to do.

The Grunt Task:

favicons: {
    options: {
        trueColor: true,
        precomposed: false,
        coast: true,
        windowsTile: true,
        tileBlackWhite: true,
    },
    files: {
        src: ['<%= config.src %>/img/favicon.png'],
        dest: '<%= config.dest %>/img/icons/'
    }
},

The console output:

$ grunt favicons
Running "favicons:files" (favicons) task
>> Created output folder at " public/assets/img/icons/ "
Resizing images for "app/assets/img/favicon.png"... OK
favicon.ico... OK
favicon.png... OK
apple-touch-icon.png... OK
apple-touch-icon-60x60-precomposed.png... OK
apple-touch-icon-72x72.png... OK
apple-touch-icon-76x76-precomposed.png... OK
apple-touch-icon-114x114.png... OK
apple-touch-icon-120x120-precomposed.png... OK
apple-touch-icon-144x144.png... OK
apple-touch-icon-152x152-precomposed.png... OK
coast-icon-228x228.png... OK
windows-tile-144x144.png... OK

Solution

  • grunt-favicons doesn't check the response from imagemagick for errors, so probably the imagemagick commands are all failing while grunt-favicons politely tells you "OK". My guess is that you're probably missing a library for converting PNG.

    You should see something like this:

    $ convert -list configure | grep DELEGATES
    DELEGATES      jng jpeg png ps zlib
    

    If png is missing, then that's your problem. sudo apt-get install libpng-dev and then I think you need to reinstall Imagemagick (I'm not certain, but that's what I did).