Search code examples
imagemagickgraphicsmagick

Recipe to generate Windows ICO files with Graphicsmagick


Based on this question for imagemagick, what is the equivalent for graphicsmagick? Recipe for creating Windows ICO files with ImageMagick?

Also I just want to generate a fully transparent ico file with multiple sizes. I found that there's an xc:none option that works for both, but is there one single command that generates ico files with multiple sizes that is transparent? Otherwise I would have to first create a transparent png file, then create ico files from the png file.


Solution

  • AFAIK, GraphicsMagick doesn't support writing ICO format files - see here.

    Just in case anyone knows more about this mad Microsoft format and if it is maybe some sort of multi-page TIF or GIF in disguise that just needs to be renamed, the following would be one way of making a recipe in GraphicsMagick:

    #!/bin/bash
    { echo convert image.png mpr:initial; 
      echo convert mpr:initial -resize 16x16 mpr:16;
      echo convert mpr:initial -resize 32x32 mpr:32;
      echo convert mpr:initial -resize 48x48 mpr:48;
      echo convert mpr:initial -resize 64x64 mpr:64;
      echo convert mpr:16 mpr:32 mpr:48 mpr:64 -colors 256 favicon.tif; } | gm batch -prompt off
    

    For the moment, I have created a multi-page TIF as the output file and it contains the four sizes you need - but as I said, GraphicsMagick will not write a ICO file.