mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-07 22:04:46 +03:00
commentwork and minor corrections
This commit is contained in:
parent
8a8f57e568
commit
689fa83f86
|
@ -27,8 +27,6 @@ import unicodedata
|
||||||
|
|
||||||
from PIL import Image, ImageFile, _binary
|
from PIL import Image, ImageFile, _binary
|
||||||
|
|
||||||
import pdb
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -83,12 +81,12 @@ def makeunicode( s, enc="latin-1", normalizer='NFC'):
|
||||||
def Ghostscript(tile, size, fp):
|
def Ghostscript(tile, size, fp):
|
||||||
"""Render an image using Ghostscript"""
|
"""Render an image using Ghostscript"""
|
||||||
|
|
||||||
# size is either pts or pixels
|
|
||||||
|
|
||||||
# Unpack decoder tile
|
# Unpack decoder tile
|
||||||
decoder, tile, offset, data = tile[0]
|
decoder, tile, offset, data = tile[0]
|
||||||
length, bbox = data
|
length, bbox = data
|
||||||
|
|
||||||
|
# bbox is in points == 1/72 inch
|
||||||
|
# size is in pixels, a device unit
|
||||||
xpointsize = bbox[2] - bbox[0]
|
xpointsize = bbox[2] - bbox[0]
|
||||||
ypointsize = bbox[3] - bbox[1]
|
ypointsize = bbox[3] - bbox[1]
|
||||||
xdpi = size[0] / (xpointsize / 72.0)
|
xdpi = size[0] / (xpointsize / 72.0)
|
||||||
|
@ -107,16 +105,15 @@ def Ghostscript(tile, size, fp):
|
||||||
with open(infile, 'wb') as f:
|
with open(infile, 'wb') as f:
|
||||||
# fetch length of fp
|
# fetch length of fp
|
||||||
fp.seek(0, 2)
|
fp.seek(0, 2)
|
||||||
fsize = fp.tell()
|
lengthfile = fp.tell()
|
||||||
# ensure start position
|
# ensure start position
|
||||||
# go back
|
# go back
|
||||||
fp.seek(0)
|
fp.seek(0)
|
||||||
lengthfile = fsize
|
|
||||||
while lengthfile > 0:
|
while lengthfile > 0:
|
||||||
s = fp.read(min(lengthfile, 4*1024*1024))
|
s = fp.read( 4*1024*1024 )
|
||||||
if not s:
|
if not s:
|
||||||
break
|
break
|
||||||
length -= len(s)
|
lengthfile -= len(s)
|
||||||
f.write(s)
|
f.write(s)
|
||||||
|
|
||||||
# Build ghostscript command
|
# Build ghostscript command
|
||||||
|
@ -222,11 +219,10 @@ class EpsImageFile(ImageFile.ImageFile):
|
||||||
fp.seek(0)
|
fp.seek(0)
|
||||||
sb = fp.readbinary(160)
|
sb = fp.readbinary(160)
|
||||||
|
|
||||||
|
offset = 0
|
||||||
if s[:4] == "%!PS":
|
if s[:4] == "%!PS":
|
||||||
offset = 0
|
|
||||||
fp.seek(0, 2)
|
fp.seek(0, 2)
|
||||||
length = fp.tell()
|
length = fp.tell()
|
||||||
offset = 0
|
|
||||||
elif i32(sb[0:4]) == 0xC6D3D0C5:
|
elif i32(sb[0:4]) == 0xC6D3D0C5:
|
||||||
offset = i32(sb[4:8])
|
offset = i32(sb[4:8])
|
||||||
length = i32(sb[8:12])
|
length = i32(sb[8:12])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user