diff --git a/ComicCompress.csproj.user b/ComicCompress.csproj.user index c210ea3..e2ee5ae 100644 --- a/ComicCompress.csproj.user +++ b/ComicCompress.csproj.user @@ -4,7 +4,7 @@ ProjectDebugger - DEV_UFF + DEV_HOME ProjectDebugger diff --git a/Program.cs b/Program.cs index 709c267..78c9bdc 100644 --- a/Program.cs +++ b/Program.cs @@ -47,7 +47,10 @@ namespace ComicCompressor //string progVersion = "Version 2.0.1 - (12/08/2024)"; // Added support for ZEBRA PRN files, generate image and base64 for prn and image. - string progVersion = "Version 2.0.2 - (27/08/2024)"; + //string progVersion = "Version 2.0.2 - (27/08/2024)"; + + // Completed support for ZEBRA PRN files, generate image and base64 for prn and image. Using URI format for base64 files + string progVersion = "Version 2.1.0 - (28/08/2024)"; public static int Main(string[] args) => CommandLineApplication.Execute(args); @@ -84,7 +87,7 @@ namespace ComicCompressor [Option("-j|--image", Description = "process images only")] public bool DoImage { get; } = false; - [Option("-n|--prn", Description = "process images only")] + [Option("-n|--prn", Description = "Process Zebra PRN files, generate png and webp from jpeg in base64 URI format")] public bool DoPrn { get; } = false; [Option("-a|--copyall", Description = "copy all unprocessed files")] public bool DoCopyAll { get; } = false; @@ -754,9 +757,11 @@ namespace ComicCompressor FileStream outStream = new FileStream(outputFolder, FileMode.Create); using (Stream BitmapStream = System.IO.File.Open(imagefile, System.IO.FileMode.Open)) { + // Write Webp length_in = BitmapStream.Length; Image img = Image.FromStream(BitmapStream); - + + //Encode webp mBitmap = new Bitmap(img); IntPtr result; @@ -766,6 +771,7 @@ namespace ComicCompressor outStream.Flush(); outStream.Close(); + // Process images for PRN integration in Pin4ProdCrtl if (DoPrn) { var image = Image.FromStream(BitmapStream); @@ -774,6 +780,7 @@ namespace ComicCompressor { using (EncoderParameter encoderParameter = new EncoderParameter(Encoder.Quality, 33L)) { + // Write JPEG encParams.Param[0] = encoderParameter; var encoderJpeg = ImageCodecInfo.GetImageEncoders() .First(c => c.FormatID == ImageFormat.Jpeg.Guid); @@ -788,6 +795,7 @@ namespace ComicCompressor string outjpeg = outputFolder.Replace("webp", "jpeg"); + // Write base64 jpeg File.WriteAllText(outjpeg + ".base64", base64String); FileStream outStreamjpeg = new FileStream(outjpeg, FileMode.Create); @@ -805,31 +813,26 @@ namespace ComicCompressor #if true using (MemoryStream m = new MemoryStream()) { + // Write base64 webp encoder.Encode(mBitmap, m, 70); byte[] imageBytes = m.ToArray(); string base64String = Convert.ToBase64String(imageBytes); base64String = "data:image/webp;base64," + base64String; - File.WriteAllText(outputFolder + ".base64", base64String); + // regen image from base64 as debug //byte[] imageBytes_o = Convert.FromBase64String(base64String); //using (MemoryStream ms = new MemoryStream(imageBytes_o)) //{ // // Create image from memory stream // using (FileStream file = new FileStream(outputFolder + ".base64.webp", FileMode.Create, System.IO.FileAccess.Write)) // { - // ms.WriteTo(file); // } //} } #endif } - //encoder.Encode(mBitmap, 70, out result, out length); - //UnmanagedMemoryStream ustream = new UnmanagedMemoryStream((byte*)result, length); - //ustream.CopyTo(outStream); - //ustream.Close(); - //outStrea.Close(); } FileInfo finfo = new FileInfo(outputFolder); diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index e0f0608..65d0ded 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -27,6 +27,10 @@ "DEV_UFF": { "commandName": "Project", "commandLineArgs": "-i \"E:\\SynologyDrive\\SynologyDrive\\A\\_PRINT_TEMPLATES_\\DEV_IN\" -o \"E:\\SynologyDrive\\SynologyDrive\\A\\_PRINT_TEMPLATES_\\DEV_OUT\" -r -s -j -a -n" + }, + "DEV_HOME": { + "commandName": "Project", + "commandLineArgs": "-i \"D:\\SynologyDrive\\A\\_PRINT_TEMPLATES_\\DEV_IN\" -o \"D:\\SynologyDrive\\A\\_PRINT_TEMPLATES_\\DEV_OUT\" -r -s -j -a -n" } } } \ No newline at end of file