Skip to content
forked from cdown/icopng

Directly embed PNGs into ICO files without reencoding.

License

Notifications You must be signed in to change notification settings

axoroll7/icopng

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

icopng | Tests

icopng stores a PNG inside an ico, without converting to the traditional bitmap with alpha channel. This saves a lot of space, since PNGs can be compressed and there are tools to highly optimise them. Embedding PNG data inside a favicon.ico file is well supported by browsers, as well.

Compared to using GIMP, ImageMagick, or ICOEncoder, the resulting file can be an order of magnitude smaller with an optimised input PNG due to avoiding re-encoding. For example, with this input image, icopng's output is ~30% smaller than GIMP's re-encoded PNG, and ~900% smaller than traditional bitmap with alpha channel:

Engine Embedded format Size
icopng PNG 1.2KiB
GIMP PNG 1.7KiB
ImageMagick/GIMP BMP 17KiB

Usage

Here's an example of converting a traditional bitmap ico file to a PNG, and then into a PNG embedded into an ico file with this tool.

# `convert' is from ImageMagick
convert favicon-old.ico favicon.png

# Optional: Shrink the png further
pngquant --skip-if-larger --strip -f --ext .png favicon.png
optipng favicon.png

# Embed into new favicon.ico
icopng favicon.png favicon.ico

Why not just use...?

image::ico::ICOEncoder, or the ico crate

The image and ico crates do export PNGs inside ICO files (nice!), but they will re-encode them, thus losing all the benefits of things like optipng/pngquant.

ImageMagick

Tools like imagemagick can convert from PNG to ico, but they convert to bitmap with alpha instead of just putting the PNG into an ico container, which means the files are very large.

GIMP

GIMP can also export as a PNG inside an ICO by exporting as ICO and selecting "Compressed (PNG)", however then you don't get the benefits of pngquant/optipng.

About

Directly embed PNGs into ICO files without reencoding.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%