我曾尝试使用ImageFormat class将PNG格式的图像转换为JPG format.Then,我们尝试用另一个验证图像的工具验证图像,结果发现只有扩展名改变了,但格式仍然是png。
我们如何将给定的图像转换为JPG格式?我们是否在使用write类?我们需要调用哪些方法。请提供详细信息。
另外,我想在此上下文中讨论ImageMagic的功能。
发布于 2012-04-25 18:21:53
您需要将图像重新保存为.JPG格式。
您可以使用System.Drawing名称空间来完成此操作。看一下这里,看看这是否能完成http://msdn.microsoft.com/en-us/library/twss4wb0(v=vs.90).aspx的工作
class Program
{
static void Main(string[] args)
{
// Load the image.
System.Drawing.Image image1 = System.Drawing.Image.FromFile(@"C:\test.bmp");
// Save the image in JPEG format.
image1.Save(@"C:\test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
// Save the image in GIF format.
image1.Save(@"C:\test.gif", System.Drawing.Imaging.ImageFormat.Gif);
// Save the image in PNG format.
image1.Save(@"C:\test.png", System.Drawing.Imaging.ImageFormat.Png);
}
}https://stackoverflow.com/questions/10313626
复制相似问题