题
我可以使用什么工具将 .ICO 文件转换为 .PNG 文件?
解决方案
自由的: @图标寿司 非常适合使用图标:
特征
- icon sushi 可以将图像文件转换为图标文件,反之亦然。
- 支持 Windows Vista 大图标。(使用PNG压缩转换大图像)
- 支持 Windows XP 32 位图标。
- 支持多图标,其中在文件中包含一些图标。
- 编辑 Alpha 通道和透明度蒙版。
- 打开 1x1 到 256x256 尺寸的图像。
- 打开1/4/8/24/32位彩色图像。
- 打开:ICO/BMP/PNG/PSD/EXE/DLL/ICL,转换为:ICO/BMP/PNG/ICL
- 复制到/从剪贴板粘贴。
其他提示
谷歌有一个 ico 到 png 转换器,我在上面看到的 红迪特 另一天。
ImageMagick 几乎可以将任何广泛使用的图像格式转换为另一种图像格式。
http://www.imagemagick.org/script/index.php
看 http://www.imagemagick.org/script/convert.php 尤其
大多数流行语言都有 ImageMagick 绑定。
我在 C# 中这样做很好地完成了工作
#region Usings
using System;
using System.IO;
using System.Linq;
// Next namespace requires a reference to PresentationCore
using System.Windows.Media.Imaging;
#endregion
namespace Imagetool
{
internal class Program
{
private static void Main(string[] args)
{
new Ico2Png().Run(@"C:\Icons\",
@"C:\Icons\out\");
}
}
public class Ico2Png
{
public void Run(string inPath, string outPath)
{
if (!Directory.Exists(inPath))
{
throw new Exception("In Path does not exist");
}
if (!Directory.Exists(outPath))
{
Directory.CreateDirectory(outPath);
}
var files = Directory.GetFiles(inPath, "*.ico");
foreach (var filepath in files.Take(10))
{
Stream iconStream = new FileStream(filepath, FileMode.Open);
var decoder = new IconBitmapDecoder(
iconStream,
BitmapCreateOptions.PreservePixelFormat,
BitmapCacheOption.None);
var fileName = Path.GetFileName(filepath);
// loop through images inside the file
foreach (var frame in decoder.Frames)
{
// save file as PNG
BitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(frame);
var size = frame.PixelHeight;
// haven't tested the next lines - include them for bitdepth
// See RenniePet's answer for details
// var depth = frame.Thumbnail.Format.BitsPerPixel;
// var path = outPath + fileName + size + depth +".png";
var path = outPath + fileName + size + ".png";
using (Stream saveStream = new FileStream(path, FileMode.Create))
{
encoder.Save(saveStream);
}
}
}
}
}
}
笔记: :当问这个问题时,这是免费的,但显然这是一个付费应用程序。@Sean Kearon 现在应该更改“正确答案”。
您可以使用 ICOFX ($59)
它是图标创建,提取和编辑的多合一解决方案。它旨在与Windows XP,Windows Vista和Macintosh图标一起使用,以支持透明度。
ConvertICO.com 对我来说一直很好。
我不知道如果没有我我会在哪里 红外风扇视图. 。非常适合批量转换图像,包括 ico 到 png。
在 Mac 上的终端中:
convert favicon.ico favicon.png
如果有人想转换 Python 图像库 (PIL) 来自文件或 url 的内存中
from cStringIO import StringIO
import Image
import urllib
def to_png(path, mime="png"):
if path.startswith("http:"):
url = urllib.quote(url)
input = StringIO()
input.write(urllib.urlopen(url).read())
input.seek(0)
else:
input = open(path).read()
if input:
out = StringIO()
image = Image.open(input)
image.save(out, mime.upper())
return out.getvalue()
else:
return None
http://converticon.com/ 也是一名候选人。
查看 http://iconverticons.com/ - iConvert 允许您轻松地将 Windows ico 转换为 Mac OS X icns、SVG 转换为 Windows 图标、PNG ico 转换为 Mac OS X ico、JPG 图像转换为 Windows 图标等等。
下面是一些用于执行此操作的 C# 代码,很大程度上基于“Peter”在该线程上的回答。(如果您觉得这个答案有用,请为 Peter 的答案投票。)
/// <summary>
/// Method to extract all of the images in an ICO file as a set of PNG files. The extracted
/// images are written to the same disk folder as the input file, with extended filenames
/// indicating the size of the image (16x16, 32x32, etc.) and the bit depth of the original
/// image (typically 32, but may be 8 or 4 for some images in old ICO files, or even in new
/// ICO files that are intended to be usable in very old Windows systems). But note that the
/// PNG files themselves always have bit depth 32 - the bit depth indication only refers to
/// the source image that the PNG was created from. Note also that there seems to be a bug
/// that makes images larger than 48 x 48 and with color depth less than 32 non-functional.
///
/// This code is very much based on the answer by "Peter" on this thread:
/// http://stackoverflow.com/questions/37590/how-to-convert-ico-to-png
///
/// Plus information about how to get the color depth of the "frames" in the icon found here:
/// http://social.msdn.microsoft.com/Forums/en-US/e46a9ad8-d65e-4aad-92c0-04d57d415065/a-bug-that-renders-iconbitmapdecoder-useless
/// </summary>
/// <param name="iconFileName">full path and filename of the ICO file</param>
private static void ExtractImagesFromIconFile(string iconFileName)
{
try
{
using (Stream iconStream = new FileStream(iconFileName, FileMode.Open))
{
IconBitmapDecoder bitmapDecoder = new IconBitmapDecoder(iconStream,
BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None);
foreach (BitmapFrame bitmapFrame in bitmapDecoder.Frames)
{
int iconSize = bitmapFrame.PixelHeight;
int bitDepth = bitmapFrame.Thumbnail.Format.BitsPerPixel;
string pngFileName = Path.GetDirectoryName(iconFileName) +
Path.DirectorySeparatorChar +
Path.GetFileNameWithoutExtension(iconFileName) + "-" +
iconSize + "x" + iconSize + "-" + bitDepth + ".png";
using (Stream saveStream = new FileStream(pngFileName, FileMode.Create))
{
BitmapEncoder bitmapEncoder = new PngBitmapEncoder();
bitmapEncoder.Frames.Add(bitmapFrame);
bitmapEncoder.Save(saveStream);
}
}
}
}
catch (Exception ex)
{
MessageBox.Show("Unable to extract PNGs from ICO file: " + ex.Message,
"ExtractImagesFromIconFile", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
至少在 win7 上制作 1024x1024 或更高分辨率的 .ico 文件的免费且强大的方法,我已经测试过:)
只需保存并输入 .ico
:)
透明度很简单,加载新图像并选择高级选项,背景颜色->透明度
Windows 7 附带的 Paint 版本会将图标转换为 PNG、JPEG 等...现在。
我刚刚遇到这个问题。仅供参考,在 Paint 中打开 .ico 并另存为 .png。为我工作!
http://convertico.org/ 允许用户一步将多个 ico 文件转换为 PNG、GIF 或 JPG 文件。
这可能是一个相当愚蠢的答案,但如果您只需要一个图标,您可以只对文件夹中的图标进行屏幕截图,然后剪掉您想要的部分。当然,请确保图标显示您想要的大小并且具有白色背景。
如果您使用像 SnagIt 或 WinSnap 这样的不错的屏幕截图应用程序,区域快照应该会在几秒钟内处理它。
请注意,这不会给您带来透明度。
如果您不寻找程序化的东西,那么只需“打印屏幕”并裁剪即可。
有一个在线转换工具可以使用 http://www.html-kit.com/favicon/. 。除了生成 .ico
它还会给你一个动画 .gif
版本。
图标转换 是另一个具有调整大小选项的在线工具。
另一种选择是 伊凡维尤