Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone, im trying to develop a program using c# to compress files, but im with doubts:

1st - should i try to use one algorithm to compress all kind of files? any sugestion of algorithm?

2nd - divide the files in category's like

-Text
-Image
-Video

And use diferent algoritms? any sugestion of what should i use for each one of them?

Thanks in advance
Hug [[]]
Posted
Comments
pasztorpisti 4-Nov-12 15:42pm    
Its also important to note in case of compression algorithms that all of them have a specific tradeoff between good compression ratio and speed. For example in case of the general purpose 7zip: it has probably one of the best compression ratios however its lzma is quite computation intensive and this might be a downside when you are searching for something to use on a mobile device. Sometimes the extra compression ratio might not be a good enough reason to use a compressor instead of another that has worse compression ratio for much less computation power. We recently dropped lzma from a mobile project because the load times were not satisfying (with lzma: 20 secs, without: 5 secs) on android/arm platform (despite the fact that on the dev platform - win32 - it wasn't noticable). You should try several solutions before choosing one that is suitable for your needs. Also note that sometimes the time needed for compression isn't important because sometimes the final product contains only the decompressor to load its data and that can be an important factor! In this case a library that comes with fast general-purpose compression method and one slow ultra-compression feature to use before software release can be awesome!

Have a look at #ziplib[^]

It's fairly easy to use, so you can try out the various algorithms on the files you want to compress.

Best regards
Espen Harlinn
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 4-Nov-12 11:50am    
Sure, my 5. I also recommend 7zip for .NET. However, OP probably needs some explanation. Please see my answer.
--SA
Espen Harlinn 4-Nov-12 11:51am    
I did :-D
Sergey Alexandrovich Kryukov 4-Nov-12 12:38pm    
Thank you. :-)
--SA
Maciej Los 4-Nov-12 13:03pm    
Short and to the point, my 5!
Espen Harlinn 4-Nov-12 14:59pm    
Thank you, Maciej :-D
Having compression lossless makes a great difference compared with different lossy algorithms. While lossy algorithms differ dramatically depending on the nature of the data, with lossless algorithms, it's not so much so. It all depends on how much do you want to optimize your algorithm to the specific nature of data. Even with lossless compression, taking into account the nature of data it could be very useful for compression ratio, doing it is much more difficult. At the same time, general-purpose lossless algorithms are well-known, open source implementations are available, so I'm not sure if you even need to develop anything. (Can you find such implementation by yourself, or you might need some help?)

Please see:
http://en.wikipedia.org/wiki/Lossy_compression[^].
http://en.wikipedia.org/wiki/Lossless_compression[^].

Good luck,
—SA
 
Share this answer
 
Comments
Espen Harlinn 4-Nov-12 11:50am    
Sure enough, a 5 :-D
Sergey Alexandrovich Kryukov 4-Nov-12 11:51am    
Thank you, Espen.
--SA
Maciej Los 4-Nov-12 13:04pm    
Agree, +5!
Sergey Alexandrovich Kryukov 4-Nov-12 13:41pm    
Thank you, Maciej.
--SA
pasztorpisti 4-Nov-12 15:49pm    
+5, Mentioning lossy is very important in case of video and audio!
I agree with you guys :)

But, Espen Harlinn can i choose the algoritm that will be used to compress a file using that library ?

The kind of compression that i want to apply is only lossless...

Any sugestion for the best algoritm to use?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900