using System.Diagnostics; namespace ImageConverter { public static class Magick { public static void FileConvert(String infile, String outfile) { ProcessStartInfo psi = new ProcessStartInfo("magick"); psi.ArgumentList.Add(infile); psi.ArgumentList.Add(outfile); Process? p = Process.Start(psi); if (p==null) { throw new Exception("Could not launch magick"); } p.WaitForExit(); } public static Byte[] BmpToJpg(this Byte[] bmpbuf) { String path = Path.GetTempFileName(); String bmppath = Path.Combine(path, "magicktmp.bmp"); String jpgpath = Path.Combine(path, "magicktmp.jpg"); File.Delete(path); Directory.CreateDirectory(path); File.WriteAllBytes(bmppath, bmpbuf); FileConvert(bmppath, jpgpath); Byte[] buf = File.ReadAllBytes(jpgpath); Directory.Delete(path, true); return buf; } } }