convert eps using pnmraw instead of ppmraw

This lets Ghostscript choose the best device to use (pbmraw, pgmraw, ppmraw) based on the image data.
This commit is contained in:
Yay295 2024-08-03 18:04:05 -05:00
parent 283b41afa0
commit 3ccecd91ce
2 changed files with 8 additions and 2 deletions

View File

@ -178,7 +178,7 @@ def test_load_long_binary_data(prefix: bytes) -> None:
data = io.BytesIO(prefix + b"\n".join(simple_eps_file_with_long_binary_data)) data = io.BytesIO(prefix + b"\n".join(simple_eps_file_with_long_binary_data))
with Image.open(data) as img: with Image.open(data) as img:
img.load() img.load()
assert img.mode == "RGB" assert img.mode == "1"
assert img.size == (100, 100) assert img.size == (100, 100)
assert img.format == "EPS" assert img.format == "EPS"

View File

@ -121,7 +121,13 @@ def Ghostscript(
lengthfile -= len(s) lengthfile -= len(s)
f.write(s) f.write(s)
device = "pngalpha" if transparency else "ppmraw" if transparency:
# "RGBA"
device = "pngalpha"
else:
# "pnmraw" automatically chooses between
# PBM ("1"), PGM ("L"), and PPM ("RGB").
device = "pnmraw"
# Build Ghostscript command # Build Ghostscript command
command = [ command = [