Note that there are some explanatory texts on larger screens.

plurals
  1. POIs this possible to compress a JPEG file with zip libraries
    text
    copied!<p>As I know the jpeg file have a best compression ratio between another image extensions, and if I correct we can not more compress a jpeg file because that have best compression, so please help me about this. I create some jpegs as following:</p> <pre><code>ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); ImageCodecInfo ici = null; foreach(ImageCodecInfo codec in codecs) { if(codec.MimeType == "image/jpeg") ici = codec; } EncoderParameters ep = new EncoderParameters(); ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, _quality); using(MemoryStream ms = new MemoryStream()) { Bitmap capture = GetImage(); capture.Save(ms, ici, ep); } </code></pre> <p>And I zipped them with sharpziplib, in average every jpeg size is 130KB and after zip every file compressed to about 70KB, how it possible? there is just 2 answer I can Imagine.</p> <p>1- We can Compress Jpeg file with more compression ratio by zip libraries</p> <p>2- My jpeg file not correctly created, and we can create better jpegs (with more compression ratio as we can not more compress them with zip libraries)</p> <p>Does any one know about this? if we can create better jpegs please help me about it.</p> <p><strong>Edit:</strong></p> <p>this is my zip code to compress jpegs:</p> <pre><code>void addnewentry(MemoryStream stream, string pass, string ZipFilePath, string entryname){ ICSharpCode.SharpZipLib.Zip.ZipFile zf = new ZipFile(ZipFilePath); if(!String.IsNullOrEmpty(pass)) zf.Password = pass; StaticDataSource sds = new StaticDataSource(Stream); zf.BeginUpdate(); zf.Add(sds, entryName); zf.CommitUpdate(); zf.IsStreamOwner = true; zf.Close(); } public class StaticDataSource : IStaticDataSource { public Stream stream { get; set; } public StaticDataSource() { this.stream.Position = 0; } public StaticDataSource(Stream stream) { this.stream = stream; this.stream.Position = 0; } public Stream GetSource() { this.stream.Position = 0; return stream; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload