Ubuntu – Convert .JPG or .PNG to .ICO using terminal and back

command lineconvert

Is there a command I can use to convert a .jpg or .png or other to extension to a .ico? If possible also to resize it to be a favicon size?

I'd also like to turn it from .ico to .jpg or .png.

Best Answer

The most useful program (suite) to manipulate image is Imagemagick (sudo apt install imagemagick) and for this task you will need the convert binary.

You will need to use something like:

convert -resize x16 -gravity center -crop 16x16+0+0 input.png -flatten -colors 256 -background transparent output/favicon.ico