Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 4-Nov-12 5:33am
Comments
pasztorpisti at 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!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I agree with you guys Smile | :)
 
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?
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Comments
Espen Harlinn at 4-Nov-12 11:50am
   
Sure enough, a 5 :-D
Sergey Alexandrovich Kryukov at 4-Nov-12 11:51am
   
Thank you, Espen.
--SA
Maciej Los at 4-Nov-12 13:04pm
   
Agree, +5!
Sergey Alexandrovich Kryukov at 4-Nov-12 13:41pm
   
Thank you, Maciej.
--SA
pasztorpisti at 4-Nov-12 15:49pm
   
+5, Mentioning lossy is very important in case of video and audio!
Sergey Alexandrovich Kryukov at 4-Nov-12 19:24pm
   
Thank you.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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 at 4-Nov-12 11:51am
   
I did :-D
Sergey Alexandrovich Kryukov at 4-Nov-12 12:38pm
   
Thank you. :-)
--SA
Maciej Los at 4-Nov-12 13:03pm
   
Short and to the point, my 5!
Espen Harlinn at 4-Nov-12 14:59pm
   
Thank you, Maciej :-D
pasztorpisti at 4-Nov-12 15:45pm
   
5ed, zip is good start (and can be a good finish too).
Espen Harlinn at 4-Nov-12 15:51pm
   
Thank you, #ziplib supports bzip2 too, and it's surprisingly fast for a piece of managed code
pasztorpisti at 4-Nov-12 15:58pm
   
Managed code is interesting because with a good jit it can achieve good performance on many platforms.

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

  Print Answers RSS
0 mhegazy94 460
1 Sergey Alexandrovich Kryukov 405
2 Kornfeld Eliyahu Peter 285
3 Sibeesh KV 251
4 Gihan Liyanage 191
0 Sergey Alexandrovich Kryukov 6,775
1 OriginalGriff 6,696
2 CPallini 5,345
3 George Jonsson 3,599
4 Gihan Liyanage 2,751


Advertise | Privacy | Mobile
Web02 | 2.8.140922.1 | Last Updated 4 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100