Command line tool to create ICO(favicon) from PNG images.
Go install
go install github.com/J-Siu/go-png2ico/v2@latest
Download
go-png2ico -h
Build ICO file from PNGs
Usage:
go-png2ico <PNG file> <PNG file> ... <ICO file> [flags]
Flags:
-d, --debug Enable debug
-h, --help help for go-png2ico
-v, --verbose Verbose
--version version for go-png2ico
ICO file always create from scratch or overwrite
(no append to nor replace existing icon in ICO file)
PNG into ICO only, other format/conversion not supported
Install
go get github.com/J-Siu/go-png2ico/v2
Import
import "github.com/J-Siu/go-png2ico/v2/p2i"
ICO
type ICO struct {
Debug bool
Err error
Initialized bool
MyType string
OnErrContinue bool
File string `json:"File"`
FileHandle *os.File `json:"FileHandle"`
pngCount uint16
pngs []*PNG
}
func (t *ICO) New(file string, debug bool) *ICO
func (t *ICO) PngAdd(png *PNG) *ICO
func (t *ICO) PngAddFile(file string) *ICO
func (t *ICO) PngCount() uint16
func (t *ICO) Write() *ICO
PNG
type PNG struct {
Debug bool
Err error
Initialized bool
MyType string
OnErrContinue bool
Buf []byte `json:"Buf"`
Depth uint16 `json:"Depth"` // bit/pixel
File string `json:"File"` // filename
Height uint8 `json:"Height"`
Size uint32 `json:"Size"`
Width uint8 `json:"Width"`
}
func (t *PNG) New(debug bool) *PNG
func (t *PNG) IsPNG() bool
func (t *PNG) Read(file string) *PNG
// icoFile = ICO file to be created/overwritten
// ICO object must be initialized with New()
ico := new(p2i.ICO).New(icoFile)
// pngFile = PNG file path
// this steps can be repeated multiple times
ico.AddPngFile(pngFile)
// Create ICO file with all PNG loaded
ico.WriteAll()
Full example in root.go
https://github.com/J-Siu/go-png2ico/releases
The MIT License
Copyright (c) 2025 John Siu
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Go
100.0%
Command line tool to create ICO(favicon) from PNG images.
Go install
go install github.com/J-Siu/go-png2ico/v2@latest
Download
go-png2ico -h
Build ICO file from PNGs
Usage:
go-png2ico <PNG file> <PNG file> ... <ICO file> [flags]
Flags:
-d, --debug Enable debug
-h, --help help for go-png2ico
-v, --verbose Verbose
--version version for go-png2ico
ICO file always create from scratch or overwrite
(no append to nor replace existing icon in ICO file)
PNG into ICO only, other format/conversion not supported
Install
go get github.com/J-Siu/go-png2ico/v2
Import
import "github.com/J-Siu/go-png2ico/v2/p2i"
ICO
type ICO struct {
Debug bool
Err error
Initialized bool
MyType string
OnErrContinue bool
File string `json:"File"`
FileHandle *os.File `json:"FileHandle"`
pngCount uint16
pngs []*PNG
}
func (t *ICO) New(file string, debug bool) *ICO
func (t *ICO) PngAdd(png *PNG) *ICO
func (t *ICO) PngAddFile(file string) *ICO
func (t *ICO) PngCount() uint16
func (t *ICO) Write() *ICO
PNG
type PNG struct {
Debug bool
Err error
Initialized bool
MyType string
OnErrContinue bool
Buf []byte `json:"Buf"`
Depth uint16 `json:"Depth"` // bit/pixel
File string `json:"File"` // filename
Height uint8 `json:"Height"`
Size uint32 `json:"Size"`
Width uint8 `json:"Width"`
}
func (t *PNG) New(debug bool) *PNG
func (t *PNG) IsPNG() bool
func (t *PNG) Read(file string) *PNG
// icoFile = ICO file to be created/overwritten
// ICO object must be initialized with New()
ico := new(p2i.ICO).New(icoFile)
// pngFile = PNG file path
// this steps can be repeated multiple times
ico.AddPngFile(pngFile)
// Create ICO file with all PNG loaded
ico.WriteAll()
Full example in root.go
https://github.com/J-Siu/go-png2ico/releases
The MIT License
Copyright (c) 2025 John Siu
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Go
100.0%