如何将png图片转换为jpg格式? [英] How do I convert a png picture to jpg format?

查看:76
本文介绍了如何将png图片转换为jpg格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将png图片转换为jpg格式?

How do I convert a png picture to jpg format?

推荐答案

尝试:

Try:
Image png = Image.FromFile(@"D:\Temp\MyPic.png");
png.Save(@"D:\Temp\MyPic.jpg", ImageFormat.Jpeg);


访问此处了解...



http://msdn.microsoft.com/en-us/library/twss4wb0(v=vs。 90).aspx [ ^ ]
visit here to understand...

http://msdn.microsoft.com/en-us/library/twss4wb0(v=vs.90).aspx[^]


使用GDI +



Use GDI+

//Make sure this is in your using block
using System.Drawing;
using System.Drawing.Imaging;

private bool ChangeToJPG(string file)
{
    try
    {
        //In case you're fussy about PNGs
        if (!file.ToLower().EndsWith(".png"))
           throw new NotImplementedException("Not a png file");
        if (!System.IO.File.Exists(file))
           throw new NotImplementedException("File not found");

        Image png = Image.FromFile(file);
        png.Save(file.Replace(".png", ".jpg").Replace(".PNG", ".JPG"), ImageFormat.Jpeg);
        return true;
    }
    catch
    {
        return false;
    }
}





简单; - )



Simple ;-)


这篇关于如何将png图片转换为jpg格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆