diff options
author | Picca Frédéric-Emmanuel <picca@debian.org> | 2017-10-07 07:59:01 +0200 |
---|---|---|
committer | Picca Frédéric-Emmanuel <picca@debian.org> | 2017-10-07 07:59:01 +0200 |
commit | bfa4dba15485b4192f8bbe13345e9658c97ecf76 (patch) | |
tree | fb9c6e5860881fbde902f7cbdbd41dc4a3a9fb5d /silx/gui/plot/backends/glutils/PlotImageFile.py | |
parent | f7bdc2acff3c13a6d632c28c4569690ab106eed7 (diff) |
New upstream version 0.6.0+dfsg
Diffstat (limited to 'silx/gui/plot/backends/glutils/PlotImageFile.py')
-rw-r--r-- | silx/gui/plot/backends/glutils/PlotImageFile.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/silx/gui/plot/backends/glutils/PlotImageFile.py b/silx/gui/plot/backends/glutils/PlotImageFile.py index e4ebe24..f028ee8 100644 --- a/silx/gui/plot/backends/glutils/PlotImageFile.py +++ b/silx/gui/plot/backends/glutils/PlotImageFile.py @@ -96,7 +96,11 @@ def saveImageToFile(data, fileNameOrObj, fileFormat): if sys.version < "3.0": fileObj = open(fileNameOrObj, "wb") else: - fileObj = open(fileNameOrObj, "w", newline='') + if fileFormat in ('png', 'ppm', 'tiff'): + # Open in binary mode + fileObj = open(fileNameOrObj, 'wb') + else: + fileObj = open(fileNameOrObj, 'w', newline='') else: # Use as a file-like object fileObj = fileNameOrObj @@ -127,9 +131,9 @@ def saveImageToFile(data, fileNameOrObj, fileFormat): elif fileFormat == 'ppm': height, width = data.shape[:2] - fileObj.write('P6\n') - fileObj.write('%d %d\n' % (width, height)) - fileObj.write('255\n') + fileObj.write(b'P6\n') + fileObj.write(b'%d %d\n' % (width, height)) + fileObj.write(b'255\n') fileObj.write(data.tostring()) elif fileFormat == 'png': @@ -143,7 +147,7 @@ def saveImageToFile(data, fileNameOrObj, fileFormat): from silx.third_party.TiffIO import TiffIO tif = TiffIO(fileNameOrObj, mode='wb+') - tif.writeImage(data, info={'Title': 'PyMCA GL Snapshot'}) + tif.writeImage(data, info={'Title': 'OpenGL Plot Snapshot'}) if fileObj != fileNameOrObj: fileObj.close() |