Ask Your Question

Revision history [back]

imdecode/imwrite PNG file changes from 96 to 72 DPI

Apologies in advance for what maybe a silly noob question. I am using the following java code to read and immediately write out a PNG file (attached):

    byte[] buf = getBytesFromFile("./t2.png");
    Mat mat = imdecode(new MatOfByte(buf), IMREAD_COLOR);
    MatOfInt params = new MatOfInt(CV_IMWRITE_PNG_COMPRESSION, 0);
    imwrite("./t3.png", mat, params);

The original file has 96 dpi, and the output file has 72 dpi. Why is that? I would like for the output file to have the same settings as the original. Thanks

C:\fakepath\t2.png

imdecode/imwrite PNG file changes from 96 to 72 DPI

Apologies in advance for what maybe a silly noob question. I am using the following java code to read and immediately write out a PNG file (attached):

    byte[] buf = getBytesFromFile("./t2.png");
    Mat mat = imdecode(new MatOfByte(buf), IMREAD_COLOR);
    MatOfInt params = new MatOfInt(CV_IMWRITE_PNG_COMPRESSION, 0);
    imwrite("./t3.png", mat, params);

The original file has 96 dpi, and the output file has 72 dpi.

Also, for what its worth, the same thing happens if I replace the first 2 lines with Mat mat = imread("./t2.png");

Why is that? I would like for the output file to have the same settings as the original. Thanks

C:\fakepath\t2.png

imdecode/imwrite PNG file changes from 96 to 72 DPI

Apologies in advance for what maybe a silly noob question. I am using the following java code to read and immediately write out a PNG file (attached):

    byte[] buf = getBytesFromFile("./t2.png");
    Mat mat = imdecode(new MatOfByte(buf), IMREAD_COLOR);
    MatOfInt params = new MatOfInt(CV_IMWRITE_PNG_COMPRESSION, 0);
    imwrite("./t3.png", mat, params);

The original file has 96 dpi, and the output file has 72 dpi.

Also, for what its worth, the same thing happens if I replace the first 2 lines with Mat mat = imread("./t2.png");

Why is that? I would like for the output file to have the same settings as the original. Thanks

C:\fakepath\t2.png