public override void Prepare(ConvertInfo info) { base.Prepare(info); var outFile = Path.GetFileNameWithoutExtension(info.OutFileName); var zoom = info.GetProperty <int?>("zoom"); if (zoom != null) { outFile += ".z" + zoom.Value; } var maxWidth = info.GetProperty <int?>("max-width"); if (maxWidth != null) { outFile += ".x" + maxWidth.Value; } info.OutFileName = outFile + Path.GetExtension(info.OutFileName); }
public override Task ConvertFile(ConvertInfo info, string inFile, string outFile) { var tcs = new TaskCompletionSource <object>(); var options = new List <ConversionOption>(); var aspect = info.GetProperty <bool?>("aspect"); var use9x = info.GetProperty <bool?>("use9x"); var ice = info.GetProperty <bool?>("ice"); var zoom = info.GetProperty <int?>("zoom"); var maxWidth = info.GetProperty <int?>("max-width"); if (aspect != null) { options.Add(new ConversionOption("text-aspect", aspect == true ? "dos" : "none")); } if (use9x != null) { options.Add(new ConversionOption("text-use9x", use9x == true ? "true" : "false")); } var parameters = new ConvertParameters { InputFileName = inFile, InputFormat = info.InputFormat, OutputFileName = outFile, MaxWidth = maxWidth, Zoom = zoom ?? 1f, Options = options }; try { Global.PabloEngine.Convert(parameters); tcs.SetResult(null); } catch (Exception ex) { tcs.SetException(ex); } return(tcs.Task); }
public override void Prepare(ConvertInfo info) { base.Prepare(info); var outFile = Path.GetFileNameWithoutExtension(info.OutFileName); var zoom = info.GetProperty <int?>("zoom"); if (zoom != null) { outFile += ".z" + zoom.Value; } var maxWidth = info.GetProperty <int?>("max-width"); if (maxWidth != null) { outFile += ".x" + maxWidth.Value; } var aspect = info.GetProperty <bool?>("aspect"); if (aspect != null) { outFile += aspect == true ? ".da" : ".na"; } var use9x = info.GetProperty <bool?>("use9x"); if (use9x != null) { outFile += use9x == true ? ".9x" : ".8x"; } var ice = info.GetProperty <bool?>("ice"); if (ice != null) { outFile += ice == true ? ".ice" : ".blink"; } info.OutFileName = outFile + Path.GetExtension(info.OutFileName); }
public override Task ConvertFile(ConvertInfo info, string inFile, string outFile) { var tcs = new TaskCompletionSource <object>(); var args = new StringBuilder(); args.AppendFormat("\"{0}\" -alpha on -background none -flatten ", inFile); var maxWidth = info.GetProperty <int?>("max-width"); if (maxWidth != null) { args.AppendFormat(" -resize '{0}>'", maxWidth.Value); } args.AppendFormat(" \"{0}\"", outFile); var process = new Process { EnableRaisingEvents = true, StartInfo = new ProcessStartInfo { FileName = convertPath, Arguments = args.ToString(), UseShellExecute = false, RedirectStandardOutput = true, // turn these off (with mono) to see output errors RedirectStandardError = false, CreateNoWindow = true } }; process.Exited += (s, e) => { if (process.ExitCode == 0) { tcs.SetResult(true); } else { tcs.SetException(new Exception(process.StandardOutput.ReadToEnd())); } }; process.Start(); return(tcs.Task); }
public override Task ConvertFile(ConvertInfo info, string inFile, string outFile) { var tcs = new TaskCompletionSource <object>(); var convertExe = "PabloDraw.Console.exe"; var appPath = HttpContext.Current.Request.MapPath("~/Util"); convertExe = Path.Combine(appPath, convertExe); var args = new StringBuilder(); args.AppendFormat(" --convert \"{0}\" --out \"{1}\"", inFile, outFile); var zoom = info.GetProperty <int?>("zoom"); if (zoom != null) { args.AppendFormat(" --zoom {0:0.00}", zoom.Value / 100f); } var maxWidth = info.GetProperty <int?>("max-width"); if (maxWidth != null) { args.AppendFormat(" --max-width {0}", maxWidth.Value); } args.Append(" --platform win"); if (!string.IsNullOrEmpty(monoPath)) { // use mono to execute the command args.Insert(0, convertExe + " "); convertExe = monoPath; } // todo: logging // Console.WriteLine("Executing: {0} {1}", convertExe, args); var process = new Process { EnableRaisingEvents = true, StartInfo = new ProcessStartInfo { FileName = convertExe, Arguments = args.ToString(), WorkingDirectory = appPath, UseShellExecute = false, RedirectStandardOutput = true, // turn these off (with mono) to see output errors RedirectStandardError = true, CreateNoWindow = true } }; process.Exited += (s, e) => { if (process.ExitCode == 0) { tcs.SetResult(true); } else { tcs.SetException(new Exception(process.StandardOutput.ReadToEnd())); } }; process.Start(); return(tcs.Task); }