mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-30 18:53:28 +03:00
Fixed dimensions of 1-bit PDFs
This commit is contained in:
parent
c15dc4d7ca
commit
ae1f7c4f50
|
@ -26,6 +26,11 @@ class TestFilePdf(PillowTestCase):
|
||||||
self.assertGreater(len(pdf.pages), 1)
|
self.assertGreater(len(pdf.pages), 1)
|
||||||
else:
|
else:
|
||||||
self.assertGreater(len(pdf.pages), 0)
|
self.assertGreater(len(pdf.pages), 0)
|
||||||
|
with open(outfile, 'rb') as fp:
|
||||||
|
contents = fp.read()
|
||||||
|
size = tuple(int(d) for d in
|
||||||
|
contents.split(b'/MediaBox [ 0 0 ')[1].split(b']')[0].split())
|
||||||
|
self.assertEqual(im.size, size)
|
||||||
|
|
||||||
return outfile
|
return outfile
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,7 @@ def _save(im, fp, filename, save_all=False):
|
||||||
# FIXME: the hex encoder doesn't support packed 1-bit
|
# FIXME: the hex encoder doesn't support packed 1-bit
|
||||||
# images; do things the hard way...
|
# images; do things the hard way...
|
||||||
data = im.tobytes("raw", "1")
|
data = im.tobytes("raw", "1")
|
||||||
im = Image.new("L", (len(data), 1), None)
|
im = Image.new("L", im.size)
|
||||||
im.putdata(data)
|
im.putdata(data)
|
||||||
ImageFile._save(im, op, [("hex", (0, 0)+im.size, 0, im.mode)])
|
ImageFile._save(im, op, [("hex", (0, 0)+im.size, 0, im.mode)])
|
||||||
elif filter == "DCTDecode":
|
elif filter == "DCTDecode":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user