mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Only set row order when needed
This commit is contained in:
parent
673eb9a845
commit
6c320323b4
|
@ -311,7 +311,6 @@ class PpmDecoder(ImageFile.PyDecoder):
|
|||
|
||||
|
||||
def _save(im, fp, filename):
|
||||
row_order = 1
|
||||
if im.mode == "1":
|
||||
rawmode, head = "1;I", b"P4"
|
||||
elif im.mode == "L":
|
||||
|
@ -322,7 +321,6 @@ def _save(im, fp, filename):
|
|||
rawmode, head = "RGB", b"P6"
|
||||
elif im.mode == "F":
|
||||
rawmode, head = "F;32F", b"Pf"
|
||||
row_order = -1
|
||||
else:
|
||||
msg = f"cannot write mode {im.mode} as PPM"
|
||||
raise OSError(msg)
|
||||
|
@ -336,6 +334,7 @@ def _save(im, fp, filename):
|
|||
fp.write(b"65535\n")
|
||||
elif head == b"Pf":
|
||||
fp.write(b"-1.0\n")
|
||||
row_order = -1 if im.mode == "F" else 1
|
||||
ImageFile._save(im, fp, [("raw", (0, 0) + im.size, 0, (rawmode, 0, row_order))])
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user