Atalasoft
Welcome to Atalasoft Community Sign in | Join | Help
in

LZW-compression

Last post 17 Jun 2007, 11:11 PM by Bill Bither. 1 replies.
Sort Posts: Previous Next
  •  17 Jun 2007, 3:25 PM 12197

    LZW-compression

    Hi

    Anyone who can explain me why the atalasoft-lzw compression gives such a poor results. Via the code beneath I saved one of my standard files (flamingo.tif) two times; first uncompressed and then lzw-compressed. Here are the results of the jury:

    • flamingo.tif  44KB  (the original file)
    • flamingo_atalasoft_uncompressed.tif  39KB
    • flamingo_atalasoft_lzw  40KB (even worser then the uncompressed coding!!!)
    • flamingo_lzw  2KB  (compressed with an lzw-algorithme I programmed my own)

    My code:

    static void Main(string[] args)

    {

      string fnsrc = "c:\\images\\flamingo.tif";

      string fndst_tif_unc = "c:\\images\\flamingo_atalasoft_uncompressed.tif";

      string fndst_tif_lzw = "c:\\images\\flamingo_atalasoft_lzw.tif";

      try

      {

        Atalasoft.Imaging.AtalaImage im_src = new Atalasoft.Imaging.AtalaImage(fnsrc);

        im_src.Save(fndst_tif_unc, new TiffEncoder(TiffCompression.NoCompression), null);

        im_src.Save(fndst_tif_lzw, new TiffEncoder(TiffCompression.Lzw), null);

      }

      catch (Exception ex)

      {

         Console.WriteLine(ex.Message);

      }

    }

     

    Filed under: ,
  •  17 Jun 2007, 11:11 PM 12200 in reply to 12197

    Re: LZW-compression

    If you set the StripSize in the TiffEncoder to a value larger than the default, you'll end up with improved compression. 

    This is taken from the documentation:

    "The strip size is the number of image rows saved as a single strip in the TIFF.  The default value is -1, which will automatically calculate a strip size equal to about 8Kb of uncompressed data.  For higher compression, it often makes sense to increase this number.

    If the StripSize is greater than the image height, the actual strip size will equal the image height."


    Bill Bither
    Atalasoft
View as RSS news feed in XML