Convert .PNG to .ICO in C / C #

I want to convert .PNG files to .ICO files. I want to do this locally without any internet addiction (therefore, I cannot use online tools like converttoico.com etc.).

I found a great tool called png2ico, but it has the limitation that it can only convert images from 1X1 to 256X256 in size. Although at the moment I am changing the resolution of PNG (in C #) and compressing it to 256X256, and then using this tool I will convert it to an icon, but the image quality is not very good.

Does anyone know any native library for this or any tool (free or paid) that can help me?

Thanks.

+3
source share
3 answers

You can use the ImageMagick library, which can convert png to ico, here you can find imageMagick for .NET: http://imagemagick.codeplex.com/ .

If you need a program for this, you can try with IrFanView in batch mode ...

+4
source

Probably a little late, but here is some C # solution:

using (FileStream stream = File.OpenWrite(@"C:\temp\test.ico")) { Bitmap bitmap = (Bitmap)Image.FromFile(@"c:\temp\test.png"); Icon.FromHandle(bitmap.GetHicon()).Save(stream); } 
+27
source

ImageMagick is the most amazing CLI image management utility ever created:

 convert image.png image.ico 

It is easy, and it works with almost all formats that you throw at it.

In addition, it has an API for quite a few different languages ​​(C #, if I remember correctly).

+4
source

Source: https://habr.com/ru/post/948217/


All Articles