How to decrease the size of the .zip file generated by DotNetZip?

1

Using the library DotNetZip , I'm ziping a folder with two image files (it can be JPEG, EPS, or AI) exactly the same (for test effect), each with 7.25 MB. I get the .zip file with the size of 14.3 MB.

Apparently the compression is not being so effective, since the images are the same, the decrease should be greater, starting from the following example, is there any way to improve compression?

using (ZipFile zip = new ZipFile())
        {
            zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression; //Adicionei isso mas não surtiu efeito.
            if (Directory.Exists(Path.Combine(TempZipFiles,UniqueKey)))
                {
                    try
                    {
                      zip.AddDirectory(Path.Combine(TempZipFiles, UniqueKey), new DirectoryInfo(UniqueKey).Name);
                    }
                    catch
                    {
                        throw;
                    }
                }
            // Salva o arquivo zip para a memória
            try
            {
                byte[] buffer = new byte[16 * 1024];
                using (MemoryStream ms = new MemoryStream())
                {
                    zip.Save(ms);
                    int read;
                    while ((read = ms.Read(buffer, 0, buffer.Length)) > 0)
                    {
                        ms.Write(buffer, 0, read);
                    }
                    return ms.ToArray();
                }
            }
            catch
            {
                throw;
            }
}

I do not know if it has a relationship, but I'm typing this folder:

Andtheresultofthe.zipfileisthe+filesfolderinside:

    
asked by anonymous 19.10.2018 / 17:08

1 answer

0

Although it is already debated in the comments, just to formalize, the compression of files .jpeg and .jpg ( Joint Photographic Experts Group ) does not have much effect because this format is already a compacted form image. It would be the equivalent of compressing an already compressed file.

This site talks about the types of images, including the compressed JPEG format: link

Images with uncompressed formats such as BMP and TIFF would have a good gain when compressed.

You can try to change the compression level to a little better gain and decrease the file size a bit. I do not know how it works in the library you're using, but for example System.IO.Compression of .NET has this option: System.IO.Compression

    
19.10.2018 / 17:40