Skip to content
Victor Derks edited this page May 4, 2016 · 6 revisions

What is CharLS for?

CharLS is source code that you can use to build a JPEG-LS compliant compressor/decompressor codec. In the program you are writing you can call the CharLS codec and pass it bitmaps (sometimes called raster images), to have them encoded to JPEG-LS, or JPEG-LS streams, which CharLS will decode to bitmaps.

Usage areas of JPEG-LS

The strongest point of JPEG-LS is that you can compress images lossless, with a high compression ratio. JPEG-LS allows for compression ratios that are similar to JPEG 2000, which means that compression can go up to 1:4 for natural images, and better than 1:10 for synthetic images. This is done with a relatively simple thus fast algorithm. This makes it appropriate if you have a huge amount of images to deal with, you need the highest possible lossless compression, and apriciate high performance. This could be the case if you work with medical images, sattelite images, raw images from digital cameras, or for remote desktop applications. A modified version of JPEG-LS has been used to send images from the mars rovers down to earth!

When not to use JPEG-LS

The biggest drawback of the JPEG-LS format is that it has so far not been widely adopted. If your application writes files to be read by other applications, it is unlikely that JPEG-LS will be supported by them. Secondly, when you need to choose between JPEG-2000 and JPEG-LS, you should consider JPEG 2000 if you want to use multi-resolution images (say for images exceeding 10000 x 10000 pixels).

How complete is CharLS?

CharLS can compress and decompress using the lossless and near-lossless mode of JPEG-LS. It can do so for 2-16 bit images. It supports color images in all the JPEG-LS modes (sample, by line or by plane). JPEG-LS does not specifiy how to encode signed pixel values (which happens sometimes in medical images). If you intend to exchange those, make sure you agree how. JPEG-LS has a few features that CharLS does not support. The most important ones are:

  • RST (restart) markers. RST markers are in JPEG-LS to make it somewhat error resilient, by dividing the image in stripes, and compressing them independent of each other.
  • Images with different resolutions for the different color components.
  • Images larger than 65536x65536 pixels.
  • Images with an arbitrary # of components in sample interleaved mode. If you would like to see any of these limitations to be resolved, please post them on the discussion or issue tracker pages!

Extras beyond the standard

  • CharLS supports three types of color transforms, identical to the transforms supported in the HP sample code. CharLS will read and write the same tags that the HP implementation uses to signal their use.
  • CharLS can decode directly into windows bitmaps (BGR and BGRA format)
  • CharLS can parse some JFIF tags if they are stored in the Jpeg-LS image.

What platforms does CharLS run on?

CharLS has been shown to work on windows (64/32/xp/vista), linux (64/32 bit), Intel based macs. Not all changesets are tested on all of these platforms. windows & linux 32 bit are tested the most frequent. You need a good C++ compiler (GCC or VC++ will do). CharLS uses a little bit of stl on the inside. If your compiler does not come with a STL library, take a look at stlport. [url:http://sourceforge.net/projects/stlport/] CharLS API (see [ApiDocumentation])consists of a handfull of functions you can call with C (not C++) linkage. This will be straigtforward to use from any C/C++ compiler. From other languages, you should read how the code can interop with code written in other languages. From VB, C# you'd be required to retype the structs passed into the API's in terms of those languages, and define function prototypes. From Java, I would suggest to use JNI. You should be able to build CharLS and the JNI glue code into the same shared library.

Building CharLS

Clone this wiki locally