SgtMeowBlank
SgtMeowBlank

Reputation: 74

Saving a tiff file with Bitmap.Save() creates a file with tenfold size?

I was asking myself, why the size of my original tiff is increasing (from 992KB to 9,42 MB), when i save it with Bitmap.Save(). The question came up, because i currently work with tiffs, modifiy them and so on.

I saw two differencen between the files (besides the file size).

  1. The compression. The originalTiff has no compression displayed in its details. The savedTiff has LZW compression.
  2. The photometric interpretation. The originalTiffs photometric interpretation is YCbCR. The savedTiffs is RGB.

Is one of these properties the cause of the tenfold size increase?

This is the code i use:

Bitmap bmp = new Bitmap(@"C:\Users\PJ.ITAMS\Deskto\originalTiff.tif");
bmp.Save(@"C:\Users\PJ.ITAMS\Desktop\savedTiff.tif",ImageFormat.Tiff);
bmp.Dispose();

If anything is unclear or i gave too little information i'm sorry and give you everything you ask for! Thanks in advance.

Upvotes: 3

Views: 4301

Answers (1)

Gwen Royakkers
Gwen Royakkers

Reputation: 441

The file size is larger Because you didn't specify a compression. This way the file is saved as an uncompressed tif.

The save Function of the Bitmap class is also overloaded with a function that takes EncoderParameters as an argument. This is how you control compression.

you can find more information here: MSDN documentation of Image.Save (The Bitmap Class implements Image)

Upvotes: 1

Related Questions