【发布时间】:2013-10-09 07:06:03
【问题描述】:
我正在尝试将许多(1000 多张)图像从 tiff 转换为 jpg,但在 appr. 250-300 张图像,任何其他图像大约需要 5-10 秒,即使前 250 张需要 20 秒。
这是我使用的代码:
foreach (string filePath in Directory.GetFiles(tifPath, "*.tif", SearchOption.AllDirectories))
{
System.Drawing.Image.FromFile(filePath).Save(jpgPath + "\\" + Path.GetFileNameWithoutExtension(filePath) + ".jpg", ImageFormat.Jpeg);
}
我的方法有问题吗?提前致谢。
【问题讨论】:
-
您可以将从 Directory.GetFiles 收到的文件保存到一个变量中,这样程序就不必多次执行该搜索
-
@HimBromBeere 这不是问题所在。问题是由于未释放的资源导致内存泄漏