0

I have a lot of .svg icons that each need to be converted to an .ico file that contains multiple resolutions. The background needs to be transparent.

These are the resolutions I need inside each .ico file:

16x16px
24x24px
32x32px
48x48px
64x64px
128x128px
256x256px

How do I do this in bulk? I'm on Windows 10.

Software info: I have access to the whole Adobe CC package. A free solution would be preferred.

  • 1
    I use Icon Slate, but that's a Mac OS app... IcoFX and FastIcns are the two Windows equivalents I know off the top of my head. – GerardFalla Jan 4 at 16:39
2

First you need to install imagemagick and svg2png

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null

brew install imagemagick

brew install svg2png

Second, you need to run script, which creates multiple png and pack them into ico file.

cd your_folder_with_icons
FILES=*.svg
for f in $FILES
do
    FULL_FILENAME=$f
    FILENAME=${FULL_FILENAME##*/}
    echo ${FILENAME%%.*}
    svg2png $FULL_FILENAME ${FILENAME%%.*}"_256.png" -w 256
    svg2png $FULL_FILENAME ${FILENAME%%.*}"_128.png" -w 128
    svg2png $FULL_FILENAME ${FILENAME%%.*}"_64.png" -w 64
    svg2png $FULL_FILENAME ${FILENAME%%.*}"_48.png" -w 48
    svg2png $FULL_FILENAME ${FILENAME%%.*}"_32.png" -w 32
    svg2png $FULL_FILENAME ${FILENAME%%.*}"_24.png" -w 24
    svg2png $FULL_FILENAME ${FILENAME%%.*}"_16.png" -w 16
    magick convert ${FILENAME%%.*}"_256.png" ${FILENAME%%.*}"_128.png" ${FILENAME%%.*}"_64.png" ${FILENAME%%.*}"_48.png" ${FILENAME%%.*}"_32.png" ${FILENAME%%.*}"_24.png" ${FILENAME%%.*}"_16.png" ${FILENAME%%.*}.ico
done

Profit!

enter image description here

Update for windows with Inkscape:

Install inkscape, install imagemagick, create folder with svg icons, create convert.bat in this folder, paste code, run convert.bat

:: Q:\Test\2019\01\15\SO_1394446.cmd
@Echo off&SetLocal EnableDelayedExpansion

Set inkscape="C:\Program Files\Inkscape\inkscape.com"
Set magick="C:\Program Files\ImageMagick-7.0.7-Q16\magick.exe"

Set "Pattern= "
Set "Replace=_"

For %%a in ("* *.svg") Do (
    Set "File=%%~a"
    Ren "%%a" "!File:%Pattern%=%Replace%!"
)

for %%f in (*.svg) do (
    for %%r in (256 128 64 48 32 24 16) Do (
        %inkscape% ^
          -z ^
          --export-background-opacity=0 ^
          --export-height=%%r ^
          --export-png="%%~nf_%%rx%%r.png" ^
          --file="%%~f"  
    )
    mogrify -units "PixelsPerInch" -density 96 %%~nf_*.png

    %magick% convert %%~nf_16x16.png ^
                     %%~nf_24x24.png ^
                     %%~nf_32x32.png ^
                     %%~nf_64x64.png ^
                     %%~nf_128x128.png ^
                     %%~nf_256x256.png %%~nf.ico
)
  • 1
    This thread is getting quite long. I will move it to chat but please update the answer if any relevant items come up! – Emilie Jan 12 at 3:06
0

Telegraphics have excellent Photoshop plug-in for this purpose.

  1. Download version of the Telegraphics ICO (Windows Icon) Format plugin that suits your system.
  2. Install plug-in by copying it to Photoshop plug-ins directory, restart Photoshop.
  3. Start Photoshop and check if under Help -> About Plug-Ins is a ICO plug-in mentioned.
  4. Create new document 256x256 px. Place your PNG image as smart object. Adjust size and position of object, if needed.
  5. File -> Save As.. and choose ICO format.
  6. Change size of image to smaller and repeat previous step.

As you understand, you can easy create Action for this if manual adjustment of the PNG is not needed and run it as a script for all sizes.

  • If I understand you correctly this creates only one resolution per .ico, I'm looking for a multi resolution .ico – Gerlof Leuhof Jan 11 at 8:51
  • One ico file will always be only in one resolution. For every resolution you need to save separate ico file. Just record action for all resolutions and run it on every PNG file you need to save. If you are not familiar with Photoshop Actions, take a look at this brief explanation: helpx.adobe.com/photoshop/using/creating-actions.html – mrserge Jan 11 at 9:00
  • @mrserge, you're wrong. Ico file format can contain multiple images, sort of like a multipage pdf or a gif with multiple frames. This plugin just doesn't do that... though it makes sense since old timey Photoshop only has a single artboard. How would you save that as a single file with multiple sizes. The plugin could now perhaps be made to support it in PS CC since it has artboards. – Joonas Jan 11 at 9:29
  • This plug in does work in PS CC – mrserge Jan 11 at 20:42
  • That is not what I'm saying. The plugin works, it's just that none of its versions support stuffing multiple sizes into one ico file and that is a limitation of the plugin, not the ico format. – Joonas Jan 12 at 2:54
-1

Use grunt with following plugin. https://github.com/andismith/grunt-responsive-images

Don't forget to install Graphic magic http://sourceforge.net/projects/graphicsmagick/files/graphicsmagick/

 responsive_images: {
      dev: {
        options: {
          sizes: [
            {
              width: 360,
              name: 'small'
            },
            {
              width: 1600,
              name: 'large'
            }
          ]
        },
        files: [
          {
            expand: true,
            src: ['image/master-product-collection/**/*.{jpg,gif,png}'],
            cwd: 'src/',
            custom_dest: 'src/image/products/{%= width %}/'
          }
        ]
      }
    }

Even i was having the same issue at the beginning, resolved using grunt :-)

-2

How about this web app: https://convertico.com/svg-to-ico/    

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – Danielillo Jan 8 at 12:31
  • 1
    @Danielillo, don't be so pedantic. There's nothing I can add in my answer that will ensure the helpfulness of it when the link stops working. And if we disregard that... I'd claim there's no extra information that anyone should know before clicking the link. – Joonas Jan 8 at 12:53
  • This doesn't seem to result in an .ico that contains multiple resolutions. Also their .svg conversion is really buggy. If you add a moderately complex shape, it looks completely broken in the .ico file – Gerlof Leuhof Jan 8 at 12:55
  • 1
    @Joonas although I agree with you, perhaps this answer would be better off as a comment. – WELZ Jan 8 at 13:04
  • 1
    @GerlofLeuhof, well that is odd. Some of the svg files I tested were faaaar more complex. The only thing I could find out was that it's the wrench that causes it... What the issue with it might be... I have no idea. My tests with your svg... Weird. When I ran it it through the application I have used many times before on mac, which I now know has a windows version too... I had no issues with your file. The website is down right now, but I found it in the windows store](microsoft.com/p/iconvert-icons/9pps5snxx82q). – Joonas Jan 8 at 14:07

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.