From a314d4d1f877dae237fbc852fa0910367669cd90 Mon Sep 17 00:00:00 2001 From: tomse <1444539+tomse@users.noreply.github.com> Date: Mon, 4 Mar 2024 20:18:00 +0100 Subject: [PATCH] add magazine support --- .../.vs/PDFWorkflowManager/v16/.suo | Bin 188416 -> 189440 bytes .../PDFWorkflowManager/MainForm.Designer.cs | 14 + .../PDFWorkflowManager/MainForm.cs | 259 ++++++++++++++---- 3 files changed, 214 insertions(+), 59 deletions(-) diff --git a/PDFWorkflowManager/.vs/PDFWorkflowManager/v16/.suo b/PDFWorkflowManager/.vs/PDFWorkflowManager/v16/.suo index 688329b7ad713b235b319f287a3ef471c394e4b2..a57a7a237d73fd845af1653be3416649bc2a0cc0 100644 GIT binary patch delta 6962 zcmd^De{j>smH+OOWF##A{uxJrf5ix}{7Xibe_+c$;~LxeSHOUiApgL|Hnw9+1PVpM zxhCKeDzwzwK*@ngZQASQ09{a~!vuv(J2_y8p_%JVFO#F(^(HrMlZHYDaua;-$&yit z8_4u#?vJkKqka4K?S6OPzPI~!?Ve!!yTOj4#}twz$r1NvW@a#xWQa0E2xlsBdMKJX zp_WziBv=ySxb%<3=7C?aa;*079ZwGj-YJCli$XgP?FG4yqpu7<2d_)1F6cL2TLlh(Q2$~$FP^4)B6_~3T zk5r7M_8_?h(T5JRGy`kbM1yrYBCX0;S-qiLmMt@sNhGNuksmR&UbCp%6m!jIzVS7I-vXv z(&m8j7HXmBMb5p0<~Zl5oXb^3|DSqyM&DBG#^K2M-RK$>TZeORMfh!tTVmEISTk`< zPoxL0L&@J^0h8D>0!#VpRjIC;)U)iba`{*oo?|7>;%d^3;yqM~jqfO4txQKM5izI4 zTg45^Y-CggGA$+hoo(o2Ijgw6twK)wI`!ka)z$z?I&SEQnd`!$U!!7VfppOMxxwTu zSf<4HRCXu4Wz5Joe8x*&uKK6+3vHi&s5yL1ykHsITldKcdl?JLyYb7BDIt`dkjj5t zzScRMuB5Z|Won+QP3MW)Xl~J-QeH&HC1R#8dw(JkoLU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)58o?XSZa!Tf^efkigj>8r7=BrBASG_%i#;k7i zw6yp1_|V}4I_3_87}5R#agts;(Efo4G3U4BGr~^$zz(LqLc&}Jo~;XJr#~bLG4pri zb5uUCSIqgAoDLiegd~604)-Hd`|QU+jQcCOEEzmU;z*zUR}vaBa8|r_p6Gno)$2s< zI&tDRJt7Lbtx4b_KnT%jJvAd9K%&b_`VWSxSj`^i@)gmOdCJ?*E1u zgFGhi2qogyIwAv6_6fN$)p?G{oo*tbS6P%8^&uG|bnE`3;?cKBwLgWYt6V2uJVt2m zYmd8z`X2Qe1ON&Bgxxp3Zf79KoKs*5>el+RAq%{~A}ui283y3A0I(-4pkgW|L@-Gt z1hEPwR`p7dv9mRh#e+lfFF!QpZ~`e7$7+B`ow3+awE$#PmS?A$qdMx&+lYz5C^QKM zp@l6@gsIZFbnp?70*{Cl>EM~!+q|zt{Dg5+b zLT-9CEI6Wn66AZ9gL^OnwB)uikJ$GCVeS&B40sXMaCIEJD9LQ1J&UHOtU|j`gU@^u zK9M+|By2<*wF@0Wo6zj(>vyY>{b>bMB{gARGmbIfuNnCbLY>eeY(l%X3Jo|aNvKD8 zrFSN_r4$x3dnp=PUj}x0mlVH9vCS8AFnzE}GguC8;yjFtv{!(e*`EWqsDB>gUzDtZ zER?Q>tt@XfPXu`b=UaDuXG-X$C^03ZzWh1&i39+aQ*?br2c#BaSD~gOSnfeLKXk z-cxXcUG9K5A9M|t-v!z8@qj#~4L!kx=b9q~c-~C-t*q8+Qgo^6G>tZ0vsrI%obB?jk(R*;d}$%0pFeGkFXVAR7+x5P(29~byr~rDgCL__)Y)& c-@aJYee{c!<;Ist;@9}{Hq#-yaT3b@2{naE_W%F@ diff --git a/PDFWorkflowManager/PDFWorkflowManager/MainForm.Designer.cs b/PDFWorkflowManager/PDFWorkflowManager/MainForm.Designer.cs index 5c3a4a5..04cde41 100644 --- a/PDFWorkflowManager/PDFWorkflowManager/MainForm.Designer.cs +++ b/PDFWorkflowManager/PDFWorkflowManager/MainForm.Designer.cs @@ -119,6 +119,7 @@ namespace PDFWorkflowManager this.btnDisposePics = new System.Windows.Forms.Button(); this.btnDeleteTemp = new System.Windows.Forms.Button(); this.btnDeleteCacheWork = new System.Windows.Forms.Button(); + this.chkMagazines = new System.Windows.Forms.CheckBox(); this.menuStrip1.SuspendLayout(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -767,6 +768,7 @@ namespace PDFWorkflowManager // groupExport // this.groupExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.groupExport.Controls.Add(this.chkMagazines); this.groupExport.Controls.Add(this.panelBanner); this.groupExport.Controls.Add(this.panelSort); this.groupExport.Enabled = false; @@ -1028,6 +1030,16 @@ namespace PDFWorkflowManager this.btnDeleteCacheWork.UseVisualStyleBackColor = true; this.btnDeleteCacheWork.Click += new System.EventHandler(this.btnDeleteCacheWork_Click); // + // chkMagazines + // + this.chkMagazines.AutoSize = true; + this.chkMagazines.Location = new System.Drawing.Point(7, 22); + this.chkMagazines.Name = "chkMagazines"; + this.chkMagazines.Size = new System.Drawing.Size(72, 17); + this.chkMagazines.TabIndex = 56; + this.chkMagazines.Text = "Magazine"; + this.chkMagazines.UseVisualStyleBackColor = true; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -1069,6 +1081,7 @@ namespace PDFWorkflowManager this.tabPage2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); this.groupExport.ResumeLayout(false); + this.groupExport.PerformLayout(); this.panelBanner.ResumeLayout(false); this.panelSort.ResumeLayout(false); this.panelSort.PerformLayout(); @@ -1173,6 +1186,7 @@ namespace PDFWorkflowManager private System.Windows.Forms.Button btnDisposePics; private System.Windows.Forms.Button btnDeleteTemp; private System.Windows.Forms.Button btnDeleteCacheWork; + private System.Windows.Forms.CheckBox chkMagazines; } } diff --git a/PDFWorkflowManager/PDFWorkflowManager/MainForm.cs b/PDFWorkflowManager/PDFWorkflowManager/MainForm.cs index f0032e5..3576529 100644 --- a/PDFWorkflowManager/PDFWorkflowManager/MainForm.cs +++ b/PDFWorkflowManager/PDFWorkflowManager/MainForm.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; +using System.Drawing.Imaging; using System.IO; using System.Linq; using System.Security.Cryptography; @@ -145,13 +146,13 @@ namespace PDFWorkflowManager private string strExeFilePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); string bannerPage = ""; - bool sortNormal = true; private string workDir = Properties.Settings.Default.WorkDir; private string workOutDir = Properties.Settings.Default.WorkOutDir; private string origsDir = Properties.Settings.Default.OrigsDir; private string tempDir = Properties.Settings.Default.TempDir; private string strPostProcessor = Properties.Settings.Default.PostProcessor; + private string strExtension = "tif"; public MainForm() { @@ -549,6 +550,183 @@ namespace PDFWorkflowManager Application.Exit(); } + private string prepCopyToTempOutdir(int sourceFileCount, string[] strFiles, string sourceDir) + { + string tempSortDir = Path.Combine(tempDir, "sort"); + Directory.CreateDirectory(tempSortDir); + int downCount = sourceFileCount; + int upCount = 1; + + // Make this to a function + if (radioSortMagazine.Checked == true) + { + for (int i = 0; i < sourceFileCount;) + { + File.Copy(strFiles[i], Path.Combine(tempSortDir, downCount.ToString().PadLeft(4, '0') + ".tif"), true); + i++; + downCount--; + File.Copy(strFiles[i], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".tif"), true); + i++; + upCount++; + File.Copy(strFiles[i], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".tif"), true); + i++; + upCount++; + File.Copy(strFiles[i], Path.Combine(tempSortDir, downCount.ToString().PadLeft(4, '0') + ".tif"), true); + i++; + downCount--; + } + // fixme why sleep? + Thread.Sleep(1000); + } + else if (radioSortFlatBed.Checked == true) + { + for (int i = 1; i < sourceFileCount;) + { + File.Copy(strFiles[i], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".tif"), true); + i++; + upCount++; + } + File.Copy(strFiles[0], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".tif"), true); + // fixme why sleep? + Thread.Sleep(1000); + } + else if (radioSortNormal.Checked == true) + { + for (int i = 0; i < sourceFileCount;) + { + File.Copy(strFiles[i], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".tif"), true); + i++; + upCount++; + } + } + return tempSortDir; + } + + static void ConvertToJpeg(string sourceFileName, string destinationFileName, int compressionLevel, int dpi = 300) + { + try + { + // Load the source image + using (Image sourceImage = Image.FromFile(sourceFileName)) + { + // Set encoding parameters for JPEG + EncoderParameters encoderParameters = new EncoderParameters(1); + encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, compressionLevel); + + // Get the JPEG codec + ImageCodecInfo jpegCodec = GetEncoderInfo("image/jpeg"); + + // Save the image in JPEG format with specified compression level + sourceImage.Save(destinationFileName, jpegCodec, encoderParameters); + sourceImage.Dispose(); + } + } + catch (Exception ex) + { + } + } + + + static void ConvertTiffTo150DpiJpg(string inputTiffPath, string outputJpgPath) + { + using (var tiffImage = Image.FromFile(inputTiffPath)) + { + var newWidth = (int)(tiffImage.Width * 150 / tiffImage.HorizontalResolution); + var newHeight = (int)(tiffImage.Height * 150 / tiffImage.VerticalResolution); + + using (var newImage = new Bitmap(newWidth, newHeight)) + { + newImage.SetResolution(150, 150); + + using (var graphics = Graphics.FromImage(newImage)) + { + graphics.SmoothingMode = SmoothingMode.HighQuality; + graphics.InterpolationMode = InterpolationMode.HighQualityBicubic; + graphics.DrawImage(tiffImage, 0, 0, newWidth, newHeight); + } + + // Set JPEG compression level + var encoderParameters = new EncoderParameters(1); + var encoderParameter = new EncoderParameter(Encoder.Quality, 85L); // Set compression level here (0-100) + encoderParameters.Param[0] = encoderParameter; + + // Save as JPEG with 150 DPI and specified compression level + var jpegCodecInfo = GetEncoderInfo(ImageFormat.Jpeg); + newImage.Save(outputJpgPath, jpegCodecInfo, encoderParameters); + } + } + } + + static ImageCodecInfo GetEncoderInfo(string mimeType) + { + // Get image codecs for all image formats + ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); + + // Find the correct image codec + foreach (ImageCodecInfo codec in codecs) + { + if (codec.MimeType == mimeType) + { + return codec; + } + } + + // If no appropriate codec found, return null + return null; + } + + private string prepConvertToTempOutdir(int sourceFileCount, string[] strFiles, string sourceDir) + { + string tempSortDir = Path.Combine(tempDir, "sort"); + Directory.CreateDirectory(tempSortDir); + int downCount = sourceFileCount; + int upCount = 1; + if (radioSortMagazine.Checked == true) + { + for (int i = 0; i < sourceFileCount;) + { + ConvertToJpeg(strFiles[i], Path.Combine(tempSortDir, downCount.ToString().PadLeft(4, '0') + ".jpg"), 85); + i++; + downCount--; + ConvertToJpeg(strFiles[i], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".jpg"), 85); + i++; + upCount++; + ConvertToJpeg(strFiles[i], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".jpg"), 85); + i++; + upCount++; + ConvertToJpeg(strFiles[i], Path.Combine(tempSortDir, downCount.ToString().PadLeft(4, '0') + ".jpg"), 85); + i++; + downCount--; + } + // fixme why sleep? + Thread.Sleep(1000); + sourceDir = tempSortDir; + } + else if (radioSortFlatBed.Checked == true) + { + for (int i = 1; i < sourceFileCount;) + { + ConvertToJpeg(strFiles[i], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".jpg"), 85); + i++; + upCount++; + } + ConvertToJpeg(strFiles[0], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".jpg"), 85); + + // fixme why sleep? + Thread.Sleep(1000); + } + else if (radioSortNormal.Checked == true) + { + for (int i = 0; i < sourceFileCount;) + { + ConvertToJpeg(strFiles[i], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".jpg"), 85); + i++; + upCount++; + } + } + return tempSortDir; + } + private async void btnConvertToPDF_Click(object sender, EventArgs e) { try @@ -556,7 +734,6 @@ namespace PDFWorkflowManager string[] strFiles = Directory.GetFiles(workOutDir, "*.tif"); int sourceFileCount = strFiles.Length; string outputDir = Path.Combine(tempDir, "output"); - //string inputDir = txtProjectDir.Text + @"\work\out\"; Directory.CreateDirectory(outputDir); string sourceDir = workOutDir; @@ -577,52 +754,24 @@ namespace PDFWorkflowManager ); } - if (radioSortMagazine.Checked == true) + // TODO - check for magazine - finish this function + if (chkMagazines.Checked == true) { - string tempSortDir = Path.Combine(tempDir, "sort"); ; - Directory.CreateDirectory(tempSortDir); - int downCount = sourceFileCount; - int upCount = 1; - - for (int i = 0; i < sourceFileCount;) - { - File.Copy(strFiles[i], Path.Combine(tempSortDir, downCount.ToString().PadLeft(4, '0') + ".tif"), true); - i++; - downCount--; - File.Copy(strFiles[i], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".tif"), true); - i++; - upCount++; - File.Copy(strFiles[i], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".tif"), true); - i++; - upCount++; - File.Copy(strFiles[i], Path.Combine(tempSortDir, downCount.ToString().PadLeft(4, '0') + ".tif"), true); - i++; - downCount--; - } - strFiles = Directory.GetFiles(tempSortDir, "*.tif"); - Thread.Sleep(1000); - sourceDir = tempSortDir; + sourceDir = prepConvertToTempOutdir(sourceFileCount, strFiles, sourceDir); + // convert to jpg function + strExtension = "jpg"; } - else if (radioSortFlatBed.Checked == true) + else { - string tempSortDir = Path.Combine(tempDir, "sort"); ; - Directory.CreateDirectory(tempSortDir); - int downCount = sourceFileCount; - int upCount = 1; - - for (int i = 1; i < sourceFileCount;) - { - File.Copy(strFiles[i], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".tif"), true); - i++; - upCount++; - } - File.Copy(strFiles[0], Path.Combine(tempSortDir, upCount.ToString().PadLeft(4, '0') + ".tif"), true); - - strFiles = Directory.GetFiles(tempSortDir, "*.tif"); - Thread.Sleep(1000); - sourceDir = tempSortDir; + sourceDir = prepCopyToTempOutdir(sourceFileCount, strFiles, sourceDir); + strExtension = "tif"; } + strFiles = Directory.GetFiles(sourceDir, "*." + strExtension); + + + + ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.UseShellExecute = false; @@ -650,24 +799,24 @@ namespace PDFWorkflowManager { toolStripProgressBar1.Control.Invoke((MethodInvoker)delegate { - toolStripProgressBar1.Value = toolStripProgressBar1.Value + 1; + toolStripProgressBar1.Value++; }); } else { - toolStripProgressBar1.Value = toolStripProgressBar1.Value + 1; + toolStripProgressBar1.Value++; } }); }); Thread.Sleep(1000); - string[] inFiles = Directory.GetFiles(sourceDir, "*.tif"); + string[] inFiles = Directory.GetFiles(sourceDir, "*." + strExtension); string[] outFiles = Directory.GetFiles(outputDir, "*.pdf"); txtPageCount.Text = inFiles.Length.ToString(); btnMakePDF.Enabled = true; // Parallel doesn't always return full result, we pick up the missing and process them again single threaded - if (Directory.GetFiles(sourceDir, "*.tif").Length != outFiles.Length) + if (Directory.GetFiles(sourceDir, "*." + strExtension).Length != outFiles.Length) { string[] arrayInFiles = new string[inFiles.Length]; string[] arrayOutFiles = new string[outFiles.Length]; @@ -686,14 +835,14 @@ namespace PDFWorkflowManager foreach (string item in difference) { - startInfo.Arguments = "\"" + Path.Combine(sourceDir, item + ".tif") + "\"" + " " + "\"" + Path.Combine(outputDir, item) + "\"" + " -l " + selectedLanguage + " pdf txt"; + startInfo.Arguments = "\"" + Path.Combine(sourceDir, item + "." + strExtension) + "\"" + " " + "\"" + Path.Combine(outputDir, item) + "\"" + " -l " + selectedLanguage + " pdf txt"; using (var process = Process.Start(startInfo)) { process.WaitForExit(); } } - if (Directory.GetFiles(sourceDir, "*.tif").Length != Directory.GetFiles(outputDir, "*.pdf").Length) + if (Directory.GetFiles(sourceDir, "*." + strExtension).Length != Directory.GetFiles(outputDir, "*.pdf").Length) { MessageBox.Show("Not all files were converted to PDF"); } @@ -713,7 +862,7 @@ namespace PDFWorkflowManager { try { - string[] outFiles = Directory.GetFiles(workOutDir, "*.tif"); + string[] outFiles = Directory.GetFiles(workOutDir, "*." + strExtension); txtPageCount.Text = outFiles.Length.ToString(); } catch @@ -770,15 +919,7 @@ namespace PDFWorkflowManager } // Create Thumbnail - string[] outFiles; - if (sortNormal) - { - outFiles = Directory.GetFiles(workOutDir, "*.tif"); - } - else - { - outFiles = Directory.GetFiles(Path.Combine(tempDir, "sort"), "*.tif"); - } + string[] outFiles = Directory.GetFiles(Path.Combine(tempDir, "sort"), "*." + strExtension); createThumbNail(outFiles[0]); textToOcrFile(outputDir);