JPEG loseless and lossy compression
-
Hi, I want to implement JPEG loseless and lossy compression. Can anyone please help me. Darmi
There are many 'JPEG' compressions. The most common one is the lossy one supported by GDI+. Creating files using this compression in C# is trivial. There are also a number of 'lossless' compressions, including JPEG 2000, JPEG lossless, etc. For JPEG 2000, I use the Atalasoft imaging library ( the J2000 stuff is an add on, and not cheap ). There are no free implimentations of J2000 that I know of, there is a JPEG lossless dll from HP, but I never actually got around to using it, I just found it in my search for a lossless compression supported by DICOM.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
There are many 'JPEG' compressions. The most common one is the lossy one supported by GDI+. Creating files using this compression in C# is trivial. There are also a number of 'lossless' compressions, including JPEG 2000, JPEG lossless, etc. For JPEG 2000, I use the Atalasoft imaging library ( the J2000 stuff is an add on, and not cheap ). There are no free implimentations of J2000 that I know of, there is a JPEG lossless dll from HP, but I never actually got around to using it, I just found it in my search for a lossless compression supported by DICOM.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Thanks Christian Graus, But i need the implementation in C# or the algorithm to implement this compression techniques. Thanks, Darmi
I see. Well, I want a Ferrarri. Doesn't mean I can have one. Like I said, there are no C# implimentations for JPEG lossless that I know of. JPEG 2000, there are definately no free implimentations. The cheapest I found was Atalasoft, it's about $2000 plus the cost of their core library. It's very good, I use it.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hi, I want to implement JPEG loseless and lossy compression. Can anyone please help me. Darmi
Image image; ... Bitmap bmp = new Bitmap(image); ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); ImageCodecInfo ici = null; foreach(ImageCodecInfo codec in codecs) { if(codec.MimeType == "image/jpeg") ici = codec; } EncoderParameters ep = new EncoderParameters(); long quality = (long)100; // 0-lossy ... 100-loseless ep.Param[0] = new EncoderParameter(Encoder.Quality, quality); bmp.Save(fileName, ici, ep);
life is study!!!
-
Image image; ... Bitmap bmp = new Bitmap(image); ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); ImageCodecInfo ici = null; foreach(ImageCodecInfo codec in codecs) { if(codec.MimeType == "image/jpeg") ici = codec; } EncoderParameters ep = new EncoderParameters(); long quality = (long)100; // 0-lossy ... 100-loseless ep.Param[0] = new EncoderParameter(Encoder.Quality, quality); bmp.Save(fileName, ici, ep);
life is study!!!
No, you are totally wrong. Even at 100, a JPEG is lossy. It's just less so. And, as I said in my answer, there are many JPEG formats, including lossless ones. They are not supported by .NET, only the common lossy JPEG format is.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
No, you are totally wrong. Even at 100, a JPEG is lossy. It's just less so. And, as I said in my answer, there are many JPEG formats, including lossless ones. They are not supported by .NET, only the common lossy JPEG format is.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Image image; ... Bitmap bmp = new Bitmap(image); ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); ImageCodecInfo ici = null; foreach(ImageCodecInfo codec in codecs) { if(codec.MimeType == "image/jpeg") ici = codec; } EncoderParameters ep = new EncoderParameters(); long quality = (long)100; // 0-lossy ... 100-loseless ep.Param[0] = new EncoderParameter(Encoder.Quality, quality); bmp.Save(fileName, ici, ep);
life is study!!!
Hai Seishin, I have tried this method. But i read some documents indicating two different algorithms for implementing lossy and losseless - huffman algorithm.. something like this. If we can implement lossy and loseless in the above method, then why its said that there are two different algorithms for each. Morover, i came to know that JPEG is lossy itself, but loseless have different format other than .jpg. Am i correct? Please help me. Darmi