updated convert function for magazines

This commit is contained in:
tomse
2026-02-01 14:08:10 +01:00
parent 92b1182a04
commit 3e074c2264

View File

@@ -791,6 +791,7 @@ namespace PDFWorkflowManager
} }
*/ */
} }
private async Task prepConvertToTempOutdir(string[] strFiles) private async Task prepConvertToTempOutdir(string[] strFiles)
{ {
try try
@@ -807,32 +808,25 @@ namespace PDFWorkflowManager
toolStripProgressBar1.Value = 0; toolStripProgressBar1.Value = 0;
toolStripStatusLabel1.Text = "Converting files to jpg."; toolStripStatusLabel1.Text = "Converting files to jpg.";
List<Task> tasks = new List<Task>(); // Convert to jpg 300 DPI
await Task.Run(() => await Task.Run(() =>
{ {
Parallel.ForEach(strFiles, async inputFile => Parallel.ForEach(strFiles, inputFile =>
{ {
outputFile = Path.Combine(tempJpg300Dir, Path.GetFileNameWithoutExtension(inputFile) + ".jpg"); outputFile = Path.Combine(tempJpg300Dir, Path.GetFileNameWithoutExtension(inputFile) + ".jpg");
convertToJpeg(inputFile, outputFile, 85, 300); convertToJpeg(inputFile, outputFile, 85, 300);
//Interlocked.Increment(ref toolStripProgressBar1.Value);
//UpdateProgressBar();
}); });
}); });
// Convert to jpg 150 DPI
await Task.Run(() => await Task.Run(() =>
{ {
Parallel.ForEach(strFiles, async inputFile => Parallel.ForEach(strFiles, inputFile =>
{ {
outputFile = Path.Combine(tempJpg150Dir, Path.GetFileNameWithoutExtension(inputFile) + ".jpg"); outputFile = Path.Combine(tempJpg150Dir, Path.GetFileNameWithoutExtension(inputFile) + ".jpg");
convertToJpeg(inputFile, outputFile, 85, 150); convertToJpeg(inputFile, outputFile, 85, 150);
//Interlocked.Increment(ref toolStripProgressBar1.Value);
//UpdateProgressBar();
}); });
}); });
await Task.WhenAll(tasks);
} }
finally finally
{ {
@@ -854,6 +848,7 @@ namespace PDFWorkflowManager
toolStripProgressBar1.Value++; toolStripProgressBar1.Value++;
} }
} }
private async void btnConvertToPDF_Click(object sender, EventArgs e) private async void btnConvertToPDF_Click(object sender, EventArgs e)
{ {
try try
@@ -1484,7 +1479,7 @@ namespace PDFWorkflowManager
txtProjectDir.Text = dict.ContainsKey("ProjectDir") ? dict["ProjectDir"] : ""; txtProjectDir.Text = dict.ContainsKey("ProjectDir") ? dict["ProjectDir"] : "";
// MessageBox.Show("Loaded file: " + loadedProjectFilePath, "File Loaded", MessageBoxButtons.OK, MessageBoxIcon.Information); // MessageBox.Show("Loaded file: " + loadedProjectFilePath, "File Loaded", MessageBoxButtons.OK, MessageBoxIcon.Information);
toolStripStatusLabel1.Text = "Project file loaded: "; toolStripStatusLabel1.Text = "Project file loaded.";
} }
} }
} }