V3.x
Moved functionalities to library iMGcompress-core
This commit is contained in:
+9
-8
@@ -14,6 +14,7 @@ using javax.swing.plaf;
|
||||
using SharpCompress.Readers;
|
||||
using SharpCompress.Writers;
|
||||
using SharpCompress.Compressors.Xz;
|
||||
using iMGcompress_core;
|
||||
//using SixLabors.ImageSharp;
|
||||
//using SixLabors.ImageSharp;
|
||||
//using SixLabors.ImageSharp.Processing;
|
||||
@@ -31,8 +32,8 @@ namespace ComicCompressor
|
||||
{
|
||||
Logger = logger;
|
||||
}
|
||||
|
||||
public void Compress(string filename, string outputFile = null)
|
||||
#if true
|
||||
public void Compress(string filename, string outputFile = null, Dictionary<string, file_stat> file_statistics = null)
|
||||
{
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
outputFile = Path.ChangeExtension(outputFile ?? filename, "cbz");
|
||||
@@ -91,12 +92,12 @@ namespace ComicCompressor
|
||||
}
|
||||
}
|
||||
else
|
||||
(save, num_pages) = ProcessArchive(archive, outputFile, filename);
|
||||
(save, num_pages) = ProcessArchive(archive, outputFile, filename, file_statistics);
|
||||
if (num_pages == 0) num_pages = 1;
|
||||
long elapsed = sw.ElapsedMilliseconds;
|
||||
Logger.Log($"\r\nFinished({save.ToString("0.##")}%) [{elapsed}][{elapsed / num_pages}]: " + filename, LogLevel.Verbose, col: Color.Green);
|
||||
}
|
||||
|
||||
#endif
|
||||
private (double, int) ProcessReader(IArchive archive, IReader reader, string outputPath)
|
||||
{
|
||||
var encoder = new SimpleEncoder();
|
||||
@@ -179,7 +180,7 @@ namespace ComicCompressor
|
||||
{
|
||||
return ((value % (place * 10)) - (value % place)) / place;
|
||||
}
|
||||
private (double, int) ProcessArchive(IArchive archive, string outputPath, string inputPath)
|
||||
private (double, int) ProcessArchive(IArchive archive, string outputPath, string inputPath, Dictionary<string, file_stat> file_statistics = null)
|
||||
{
|
||||
//var fileEntries = archive.Entries.Where(e => !e.IsDirectory);
|
||||
var fileEntries = archive.Entries.Where(e => !e.IsDirectory).OrderBy(e => e.Key);
|
||||
@@ -226,13 +227,13 @@ namespace ComicCompressor
|
||||
|
||||
save = 100 * (double)output_length / (double)archive.TotalSize;
|
||||
|
||||
Program.file_stat fs = null;
|
||||
Program.File_statistics.TryGetValue(inputPath, out fs);
|
||||
file_stat fs = null;
|
||||
file_statistics.TryGetValue(inputPath, out fs);
|
||||
if (fs != null)
|
||||
{
|
||||
fs.Uncompressed_file_len = archive.TotalSize;
|
||||
fs.Compressed_file_len = output_length;
|
||||
Program.File_statistics.TryAdd(inputPath, fs);
|
||||
file_statistics.TryAdd(inputPath, fs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user