"Colors -> Info -> Export Histogram" generates extra blank lines between exported rows on Windows
GIMP version: 2.10.20+, 3
Operating System: Windows
Description of the bug
"Colors -> Info -> Export Histogram" generates extra blank lines between exported rows on Windows.
Reproduction
Is the bug reproducible? Always
Reproduction steps:
- (On Windows) Use "Colors -> Info -> Export Histogram" to export a histogram to a CSV file for any RGB image.
Expected result:
There should be no blank rows in the file.
Actual result:
Every row of data is followed by a blank row.
Additional information
More specifically, every line in the CSV file ends with '\r\r\n', whereas they should end with '\r\n'. The extra '\r' can result in blank rows when the file is imported into a spreadsheet (such as OpenOffice Calc).
The problem has to do with how the CSV output file is opened for writing. Python 2.7 documentation for csv.writer()
states the the file must be opened with mode wb
on platforms (such as Windows) where that makes a difference. The current python plugin (line 61) opens the file with mode wt
. The csv
python module uses \r\n
as a line terminator on all platforms. On Windows, files opened in mode wt
have all \n
line endings translated to \r\n
when writing. Hence, \r\n
becomes \r\r\n
.
For python 3 (Gimp 3), the csv.writer()
documentation states that the file must be opened with the newline=''
parameter, for the same reasons. That would affect line 118 of this code in Gimp 3.