mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-11 08:42:35 +03:00
pep8 and pyflakes
This commit is contained in:
parent
8cda5170c8
commit
3ff73688fe
|
@ -46,9 +46,11 @@ def _obj(fp, obj, **dict):
|
||||||
fp.write("/%s %s\n" % (k, v))
|
fp.write("/%s %s\n" % (k, v))
|
||||||
fp.write(">>\n")
|
fp.write(">>\n")
|
||||||
|
|
||||||
|
|
||||||
def _endobj(fp):
|
def _endobj(fp):
|
||||||
fp.write("endobj\n")
|
fp.write("endobj\n")
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# (Internal) Image save plugin for the PDF format.
|
# (Internal) Image save plugin for the PDF format.
|
||||||
|
|
||||||
|
@ -64,8 +66,10 @@ def _save(im, fp, filename):
|
||||||
class TextWriter:
|
class TextWriter:
|
||||||
def __init__(self, fp):
|
def __init__(self, fp):
|
||||||
self.fp = fp
|
self.fp = fp
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
return getattr(self.fp, name)
|
return getattr(self.fp, name)
|
||||||
|
|
||||||
def write(self, value):
|
def write(self, value):
|
||||||
self.fp.write(value.encode('latin-1'))
|
self.fp.write(value.encode('latin-1'))
|
||||||
|
|
||||||
|
@ -122,7 +126,9 @@ def _save(im, fp, filename):
|
||||||
# catalogue
|
# catalogue
|
||||||
|
|
||||||
xref[1] = fp.tell()
|
xref[1] = fp.tell()
|
||||||
_obj(fp, 1, Type = "/Catalog",
|
_obj(
|
||||||
|
fp, 1,
|
||||||
|
Type="/Catalog",
|
||||||
Pages="2 0 R")
|
Pages="2 0 R")
|
||||||
_endobj(fp)
|
_endobj(fp)
|
||||||
|
|
||||||
|
@ -130,7 +136,9 @@ def _save(im, fp, filename):
|
||||||
# pages
|
# pages
|
||||||
|
|
||||||
xref[2] = fp.tell()
|
xref[2] = fp.tell()
|
||||||
_obj(fp, 2, Type = "/Pages",
|
_obj(
|
||||||
|
fp, 2,
|
||||||
|
Type="/Pages",
|
||||||
Count=1,
|
Count=1,
|
||||||
Kids="[4 0 R]")
|
Kids="[4 0 R]")
|
||||||
_endobj(fp)
|
_endobj(fp)
|
||||||
|
@ -158,7 +166,9 @@ def _save(im, fp, filename):
|
||||||
raise ValueError("unsupported PDF filter (%s)" % filter)
|
raise ValueError("unsupported PDF filter (%s)" % filter)
|
||||||
|
|
||||||
xref[3] = fp.tell()
|
xref[3] = fp.tell()
|
||||||
_obj(fp, 3, Type = "/XObject",
|
_obj(
|
||||||
|
fp, 3,
|
||||||
|
Type="/XObject",
|
||||||
Subtype="/Image",
|
Subtype="/Image",
|
||||||
Width=width, # * 72.0 / resolution,
|
Width=width, # * 72.0 / resolution,
|
||||||
Height=height, # * 72.0 / resolution,
|
Height=height, # * 72.0 / resolution,
|
||||||
|
@ -179,11 +189,14 @@ def _save(im, fp, filename):
|
||||||
|
|
||||||
xref[4] = fp.tell()
|
xref[4] = fp.tell()
|
||||||
_obj(fp, 4)
|
_obj(fp, 4)
|
||||||
fp.write("<<\n/Type /Page\n/Parent 2 0 R\n"\
|
fp.write(
|
||||||
"/Resources <<\n/ProcSet [ /PDF %s ]\n"\
|
"<<\n/Type /Page\n/Parent 2 0 R\n"
|
||||||
"/XObject << /image 3 0 R >>\n>>\n"\
|
"/Resources <<\n/ProcSet [ /PDF %s ]\n"
|
||||||
"/MediaBox [ 0 0 %d %d ]\n/Contents 5 0 R\n>>\n" %\
|
"/XObject << /image 3 0 R >>\n>>\n"
|
||||||
(procset, int(width * 72.0 /resolution) , int(height * 72.0 / resolution)))
|
"/MediaBox [ 0 0 %d %d ]\n/Contents 5 0 R\n>>\n" % (
|
||||||
|
procset,
|
||||||
|
int(width * 72.0 / resolution),
|
||||||
|
int(height * 72.0 / resolution)))
|
||||||
_endobj(fp)
|
_endobj(fp)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -191,7 +204,10 @@ def _save(im, fp, filename):
|
||||||
|
|
||||||
op = TextWriter(io.BytesIO())
|
op = TextWriter(io.BytesIO())
|
||||||
|
|
||||||
op.write("q %d 0 0 %d 0 0 cm /image Do Q\n" % (int(width * 72.0 / resolution), int(height * 72.0 / resolution)))
|
op.write(
|
||||||
|
"q %d 0 0 %d 0 0 cm /image Do Q\n" % (
|
||||||
|
int(width * 72.0 / resolution),
|
||||||
|
int(height * 72.0 / resolution)))
|
||||||
|
|
||||||
xref[5] = fp.tell()
|
xref[5] = fp.tell()
|
||||||
_obj(fp, 5, Length=len(op.fp.getvalue()))
|
_obj(fp, 5, Length=len(op.fp.getvalue()))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user