# Revision history [back]

### png compression

Why does the png-file-size increase? Here is the code (in Java):

Mat m = Highgui.imread("C:/img1.png");
Highgui.imwrite("C:/img1out.png", m);


Initially the "img1.png"-file is 900kb, but "img1out.png" becomes 2200kb! I have read that the compression in openCV is not as good as in other image-processing API's, but recently some compression has been added.

I tried out to do this here:

Mat m = Highgui.imread("C:/img1.png");
MatOfInt mPngCompressionRate = new MatOfInt(9);
Highgui.imwrite("C:/img1out.png", m, mPngCompressionRate);


But it saves only a completely black image. What am i doing wrong here ?

### png compression

Why does the png-file-size increase? Here is the code (in Java):

Mat m = Highgui.imread("C:/img1.png");
Highgui.imwrite("C:/img1out.png", m);


Initially the "img1.png"-file is 900kb, but "img1out.png" becomes 2200kb! I have read that the compression in openCV is not as good as in other image-processing API's, but recently some compression has been added.

I tried out to do this here:

Mat m = Highgui.imread("C:/img1.png");
MatOfInt mPngCompressionRate = new MatOfInt(9);
Highgui.imwrite("C:/img1out.png", m, mPngCompressionRate);


But it saves only a completely black image. the size remains same. What am i doing wrong here ?

### png compression

Why does the png-file-size increase? Here is the code (in Java):

Mat m = Highgui.imread("C:/img1.png");
Highgui.imwrite("C:/img1out.png", m);


Initially the "img1.png"-file is 900kb, but "img1out.png" becomes 2200kb! I have read that the compression in openCV is not as good as in other image-processing API's, but recently some compression has been added.

I tried out to do this here:

Mat m = Highgui.imread("C:/img1.png");
MatOfInt mPngCompressionRate = new MatOfInt(9);
Highgui.imwrite("C:/img1out.png", m, mPngCompressionRate);


But the size remains same. still goes up to 2200kb of "img1out.png". What am i doing wrong here ?