引用-》管理NuGet程序包-》搜索GroupDocs.Conversion,安装上这个
核心代码
var dir1 = System.IO.Path.GetDirectoryName(path1);var file1 = System.IO.Path.GetFileNameWithoutExtension(path1);var full_path1 = System.IO.Path.Combine(dir1, file1 + ".jpg");var full_path2 = System.IO.Path.Combine(dir1, file1 + "_1.jpg");using (Converter converter = new Converter(path1)){ImageConvertOptions options = new ImageConvertOptions{ // Set the conversion format to JPGFormat = ImageFileType.Jpg,Width = 2480 //2480*3508};converter.Convert(full_path1, options);}Image image2 = Image.FromFile(full_path1);Graphics g = Graphics.FromImage(image2);SolidBrush brush = new SolidBrush(Color.White);g.FillRectangle(brush, 0, 0, 2480, 120);g.Dispose();image2.Save(full_path2); image2.Dispose();
源码地址:https://download.csdn.net/download/ying1979/89334389