Flake8 fixes

This commit is contained in:
Andrew Murray 2015-08-25 22:27:18 +10:00
parent 926a08cdb3
commit c6b13d294f
44 changed files with 168 additions and 173 deletions

View File

@ -24,12 +24,10 @@
# #
__version__ = "0.7"
from PIL import Image, ImageFile, ImagePalette, _binary from PIL import Image, ImageFile, ImagePalette, _binary
import math import math
__version__ = "0.7"
i8 = _binary.i8 i8 = _binary.i8
i16 = _binary.i16le i16 = _binary.i16le

View File

@ -17,10 +17,9 @@
# #
__version__ = "0.1"
from PIL import Image, BmpImagePlugin, _binary from PIL import Image, BmpImagePlugin, _binary
__version__ = "0.1"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -21,12 +21,11 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.2"
from PIL import Image, _binary from PIL import Image, _binary
from PIL.PcxImagePlugin import PcxImageFile from PIL.PcxImagePlugin import PcxImageFile
__version__ = "0.2"
MAGIC = 0x3ADE68B1 # QUIZ: what's this value, then? MAGIC = 0x3ADE68B1 # QUIZ: what's this value, then?
i32 = _binary.i32le i32 = _binary.i32le

View File

@ -20,12 +20,13 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.5"
import re import re
import io import io
import sys
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "0.5"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------
@ -36,7 +37,6 @@ split = re.compile(r"^%%([^:]*):[ \t]*(.*)[ \t]*$")
field = re.compile(r"^%[%!\w]([^:]*)[ \t]*$") field = re.compile(r"^%[%!\w]([^:]*)[ \t]*$")
gs_windows_binary = None gs_windows_binary = None
import sys
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
import shutil import shutil
if hasattr(shutil, 'which'): if hasattr(shutil, 'which'):
@ -187,7 +187,8 @@ class PSFile(object):
def _accept(prefix): def _accept(prefix):
return prefix[:4] == b"%!PS" or (len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5) return prefix[:4] == b"%!PS" or \
(len(prefix) >= 4 and i32(prefix) == 0xC6D3D0C5)
## ##
# Image plugin for Encapsulated Postscript. This plugin supports only # Image plugin for Encapsulated Postscript. This plugin supports only

View File

@ -16,10 +16,10 @@
# #
__version__ = "0.2"
from PIL import Image, ImageFile, ImagePalette, _binary from PIL import Image, ImageFile, ImagePalette, _binary
__version__ = "0.2"
i8 = _binary.i8 i8 = _binary.i8
i16 = _binary.i16le i16 = _binary.i16le
i32 = _binary.i32le i32 = _binary.i32le

View File

@ -16,12 +16,11 @@
# #
__version__ = "0.1"
from PIL import Image, ImageFile from PIL import Image, ImageFile
from PIL.OleFileIO import i8, i32, MAGIC, OleFileIO from PIL.OleFileIO import i8, i32, MAGIC, OleFileIO
__version__ = "0.1"
# we map from colour field tuples to (mode, rawmode) descriptors # we map from colour field tuples to (mode, rawmode) descriptors
MODES = { MODES = {

View File

@ -23,11 +23,11 @@
# purposes only. # purposes only.
__version__ = "0.1"
from PIL import ImageFile, ImagePalette, _binary from PIL import ImageFile, ImagePalette, _binary
from PIL._util import isPath from PIL._util import isPath
__version__ = "0.1"
try: try:
import builtins import builtins
except ImportError: except ImportError:

View File

@ -22,14 +22,14 @@
# * http://msdn.microsoft.com/en-us/library/ms997538.aspx # * http://msdn.microsoft.com/en-us/library/ms997538.aspx
__version__ = "0.1"
import struct import struct
from io import BytesIO from io import BytesIO
from PIL import Image, ImageFile, BmpImagePlugin, PngImagePlugin, _binary from PIL import Image, ImageFile, BmpImagePlugin, PngImagePlugin, _binary
from math import log, ceil from math import log, ceil
__version__ = "0.1"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -26,12 +26,12 @@
# #
__version__ = "0.7"
import re import re
from PIL import Image, ImageFile, ImagePalette from PIL import Image, ImageFile, ImagePalette
from PIL._binary import i8 from PIL._binary import i8
__version__ = "0.7"
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# Standard tags # Standard tags

View File

@ -33,7 +33,7 @@ import io
import logging import logging
import os import os
import sys import sys
import traceback # import traceback
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -275,7 +275,8 @@ def truetype(font=None, size=10, index=0, encoding="", filename=None):
# According to the freedesktop spec, XDG_DATA_DIRS should # According to the freedesktop spec, XDG_DATA_DIRS should
# default to /usr/share # default to /usr/share
lindirs = '/usr/share' lindirs = '/usr/share'
dirs += [os.path.join(lindir, "fonts") for lindir in lindirs.split(":")] dirs += [os.path.join(lindir, "fonts")
for lindir in lindirs.split(":")]
elif sys.platform == 'darwin': elif sys.platform == 'darwin':
dirs += ['/Library/Fonts', '/System/Library/Fonts', dirs += ['/Library/Fonts', '/System/Library/Fonts',
os.path.expanduser('~/Library/Fonts')] os.path.expanduser('~/Library/Fonts')]

View File

@ -237,8 +237,8 @@ def load(filename):
p = PaletteFile.PaletteFile(fp) p = PaletteFile.PaletteFile(fp)
lut = p.getpalette() lut = p.getpalette()
except (SyntaxError, ValueError): except (SyntaxError, ValueError):
#import traceback # import traceback
#traceback.print_exc() # traceback.print_exc()
pass pass
if not lut: if not lut:

View File

@ -15,12 +15,13 @@
# #
__version__ = "0.2"
import re import re
from PIL import Image, ImageFile from PIL import Image, ImageFile
__version__ = "0.2"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -17,13 +17,12 @@
from __future__ import print_function from __future__ import print_function
__version__ = "0.3"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
import os import os
import tempfile import tempfile
__version__ = "0.3"
i8 = _binary.i8 i8 = _binary.i8
i16 = _binary.i16be i16 = _binary.i16be
i32 = _binary.i32be i32 = _binary.i32be

View File

@ -32,8 +32,6 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.6"
import array import array
import struct import struct
import io import io
@ -48,6 +46,8 @@ o8 = _binary.o8
i16 = _binary.i16be i16 = _binary.i16be
i32 = _binary.i32be i32 = _binary.i32be
__version__ = "0.6"
# #
# Parser # Parser
@ -528,14 +528,14 @@ RAWMODE = {
"YCbCr": "YCbCr", "YCbCr": "YCbCr",
} }
zigzag_index = ( 0, 1, 5, 6, 14, 15, 27, 28, zigzag_index = (0, 1, 5, 6, 14, 15, 27, 28,
2, 4, 7, 13, 16, 26, 29, 42, 2, 4, 7, 13, 16, 26, 29, 42,
3, 8, 12, 17, 25, 30, 41, 43, 3, 8, 12, 17, 25, 30, 41, 43,
9, 11, 18, 24, 31, 40, 44, 53, 9, 11, 18, 24, 31, 40, 44, 53,
10, 19, 23, 32, 39, 45, 52, 54, 10, 19, 23, 32, 39, 45, 52, 54,
20, 22, 33, 38, 46, 51, 55, 60, 20, 22, 33, 38, 46, 51, 55, 60,
21, 34, 37, 47, 50, 56, 59, 61, 21, 34, 37, 47, 50, 56, 59, 61,
35, 36, 48, 49, 57, 58, 62, 63) 35, 36, 48, 49, 57, 58, 62, 63)
samplings = {(1, 1, 1, 1, 1, 1): 0, samplings = {(1, 1, 1, 1, 1, 1): 0,
(2, 1, 1, 1, 1, 1): 1, (2, 1, 1, 1, 1, 1): 1,

View File

@ -68,7 +68,7 @@ Libjpeg ref.: http://www.jpegcameras.com/libjpeg/libjpeg-3.html
presets = { presets = {
'web_low': {'subsampling': 2, # "4:1:1" 'web_low': {'subsampling': 2, # "4:1:1"
'quantization': [ 'quantization': [
[20, 16, 25, 39, 50, 46, 62, 68, [20, 16, 25, 39, 50, 46, 62, 68,
16, 18, 23, 38, 38, 53, 65, 68, 16, 18, 23, 38, 38, 53, 65, 68,
25, 23, 31, 38, 53, 65, 68, 68, 25, 23, 31, 38, 53, 65, 68, 68,
@ -85,9 +85,9 @@ presets = {
68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68] 68, 68, 68, 68, 68, 68, 68, 68]
]}, ]},
'web_medium': {'subsampling': 2, # "4:1:1" 'web_medium': {'subsampling': 2, # "4:1:1"
'quantization': [ 'quantization': [
[16, 11, 11, 16, 23, 27, 31, 30, [16, 11, 11, 16, 23, 27, 31, 30,
11, 12, 12, 15, 20, 23, 23, 30, 11, 12, 12, 15, 20, 23, 23, 30,
11, 12, 13, 16, 23, 26, 35, 47, 11, 12, 13, 16, 23, 26, 35, 47,
@ -104,10 +104,10 @@ presets = {
26, 26, 30, 39, 48, 63, 64, 64, 26, 26, 30, 39, 48, 63, 64, 64,
38, 35, 46, 53, 64, 64, 64, 64, 38, 35, 46, 53, 64, 64, 64, 64,
48, 43, 53, 64, 64, 64, 64, 64] 48, 43, 53, 64, 64, 64, 64, 64]
]}, ]},
'web_high': {'subsampling': 0, # "4:4:4" 'web_high': {'subsampling': 0, # "4:4:4"
'quantization': [ 'quantization': [
[ 6, 4, 4, 6, 9, 11, 12, 16, [6, 4, 4, 6, 9, 11, 12, 16,
4, 5, 5, 6, 8, 10, 12, 12, 4, 5, 5, 6, 8, 10, 12, 12,
4, 5, 5, 6, 10, 12, 14, 19, 4, 5, 5, 6, 10, 12, 14, 19,
6, 6, 6, 11, 12, 15, 19, 28, 6, 6, 6, 11, 12, 15, 19, 28,
@ -115,7 +115,7 @@ presets = {
11, 10, 12, 15, 20, 27, 31, 31, 11, 10, 12, 15, 20, 27, 31, 31,
12, 12, 14, 19, 27, 31, 31, 31, 12, 12, 14, 19, 27, 31, 31, 31,
16, 12, 19, 28, 31, 31, 31, 31], 16, 12, 19, 28, 31, 31, 31, 31],
[ 7, 7, 13, 24, 26, 31, 31, 31, [7, 7, 13, 24, 26, 31, 31, 31,
7, 12, 16, 21, 31, 31, 31, 31, 7, 12, 16, 21, 31, 31, 31, 31,
13, 16, 17, 31, 31, 31, 31, 31, 13, 16, 17, 31, 31, 31, 31, 31,
24, 21, 31, 31, 31, 31, 31, 31, 24, 21, 31, 31, 31, 31, 31, 31,
@ -123,10 +123,10 @@ presets = {
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31] 31, 31, 31, 31, 31, 31, 31, 31]
]}, ]},
'web_very_high': {'subsampling': 0, # "4:4:4" 'web_very_high': {'subsampling': 0, # "4:4:4"
'quantization': [ 'quantization': [
[ 2, 2, 2, 2, 3, 4, 5, 6, [2, 2, 2, 2, 3, 4, 5, 6,
2, 2, 2, 2, 3, 4, 5, 6, 2, 2, 2, 2, 3, 4, 5, 6,
2, 2, 2, 2, 4, 5, 7, 9, 2, 2, 2, 2, 4, 5, 7, 9,
2, 2, 2, 4, 5, 7, 9, 12, 2, 2, 2, 4, 5, 7, 9, 12,
@ -134,7 +134,7 @@ presets = {
4, 4, 5, 7, 10, 12, 12, 12, 4, 4, 5, 7, 10, 12, 12, 12,
5, 5, 7, 9, 12, 12, 12, 12, 5, 5, 7, 9, 12, 12, 12, 12,
6, 6, 9, 12, 12, 12, 12, 12], 6, 6, 9, 12, 12, 12, 12, 12],
[ 3, 3, 5, 9, 13, 15, 15, 15, [3, 3, 5, 9, 13, 15, 15, 15,
3, 4, 6, 11, 14, 12, 12, 12, 3, 4, 6, 11, 14, 12, 12, 12,
5, 6, 9, 14, 12, 12, 12, 12, 5, 6, 9, 14, 12, 12, 12, 12,
9, 11, 14, 12, 12, 12, 12, 12, 9, 11, 14, 12, 12, 12, 12, 12,
@ -142,10 +142,10 @@ presets = {
15, 12, 12, 12, 12, 12, 12, 12, 15, 12, 12, 12, 12, 12, 12, 12,
15, 12, 12, 12, 12, 12, 12, 12, 15, 12, 12, 12, 12, 12, 12, 12,
15, 12, 12, 12, 12, 12, 12, 12] 15, 12, 12, 12, 12, 12, 12, 12]
]}, ]},
'web_maximum': {'subsampling': 0, # "4:4:4" 'web_maximum': {'subsampling': 0, # "4:4:4"
'quantization': [ 'quantization': [
[ 1, 1, 1, 1, 1, 1, 1, 1, [1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2,
1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2,
@ -153,7 +153,7 @@ presets = {
1, 1, 1, 1, 2, 2, 3, 3, 1, 1, 1, 1, 2, 2, 3, 3,
1, 1, 1, 2, 2, 3, 3, 3, 1, 1, 1, 2, 2, 3, 3, 3,
1, 1, 2, 2, 3, 3, 3, 3], 1, 1, 2, 2, 3, 3, 3, 3],
[ 1, 1, 1, 2, 2, 3, 3, 3, [1, 1, 1, 2, 2, 3, 3, 3,
1, 1, 1, 2, 3, 3, 3, 3, 1, 1, 1, 2, 3, 3, 3, 3,
1, 1, 1, 3, 3, 3, 3, 3, 1, 1, 1, 3, 3, 3, 3, 3,
2, 2, 3, 3, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3,
@ -161,9 +161,9 @@ presets = {
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3] 3, 3, 3, 3, 3, 3, 3, 3]
]}, ]},
'low': {'subsampling': 2, # "4:1:1" 'low': {'subsampling': 2, # "4:1:1"
'quantization': [ 'quantization': [
[18, 14, 14, 21, 30, 35, 34, 17, [18, 14, 14, 21, 30, 35, 34, 17,
14, 16, 16, 19, 26, 23, 12, 12, 14, 16, 16, 19, 26, 23, 12, 12,
14, 16, 17, 21, 23, 12, 12, 12, 14, 16, 17, 21, 23, 12, 12, 12,
@ -180,9 +180,9 @@ presets = {
20, 12, 12, 12, 12, 12, 12, 12, 20, 12, 12, 12, 12, 12, 12, 12,
17, 12, 12, 12, 12, 12, 12, 12, 17, 12, 12, 12, 12, 12, 12, 12,
17, 12, 12, 12, 12, 12, 12, 12] 17, 12, 12, 12, 12, 12, 12, 12]
]}, ]},
'medium': {'subsampling': 2, # "4:1:1" 'medium': {'subsampling': 2, # "4:1:1"
'quantization': [ 'quantization': [
[12, 8, 8, 12, 17, 21, 24, 17, [12, 8, 8, 12, 17, 21, 24, 17,
8, 9, 9, 11, 15, 19, 12, 12, 8, 9, 9, 11, 15, 19, 12, 12,
8, 9, 10, 12, 19, 12, 12, 12, 8, 9, 10, 12, 19, 12, 12, 12,
@ -199,10 +199,10 @@ presets = {
20, 12, 12, 12, 12, 12, 12, 12, 20, 12, 12, 12, 12, 12, 12, 12,
17, 12, 12, 12, 12, 12, 12, 12, 17, 12, 12, 12, 12, 12, 12, 12,
17, 12, 12, 12, 12, 12, 12, 12] 17, 12, 12, 12, 12, 12, 12, 12]
]}, ]},
'high': {'subsampling': 0, # "4:4:4" 'high': {'subsampling': 0, # "4:4:4"
'quantization': [ 'quantization': [
[ 6, 4, 4, 6, 9, 11, 12, 16, [6, 4, 4, 6, 9, 11, 12, 16,
4, 5, 5, 6, 8, 10, 12, 12, 4, 5, 5, 6, 8, 10, 12, 12,
4, 5, 5, 6, 10, 12, 12, 12, 4, 5, 5, 6, 10, 12, 12, 12,
6, 6, 6, 11, 12, 12, 12, 12, 6, 6, 6, 11, 12, 12, 12, 12,
@ -210,7 +210,7 @@ presets = {
11, 10, 12, 12, 12, 12, 12, 12, 11, 10, 12, 12, 12, 12, 12, 12,
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
16, 12, 12, 12, 12, 12, 12, 12], 16, 12, 12, 12, 12, 12, 12, 12],
[ 7, 7, 13, 24, 20, 20, 17, 17, [7, 7, 13, 24, 20, 20, 17, 17,
7, 12, 16, 14, 14, 12, 12, 12, 7, 12, 16, 14, 14, 12, 12, 12,
13, 16, 14, 14, 12, 12, 12, 12, 13, 16, 14, 14, 12, 12, 12, 12,
24, 14, 14, 12, 12, 12, 12, 12, 24, 14, 14, 12, 12, 12, 12, 12,
@ -218,10 +218,10 @@ presets = {
20, 12, 12, 12, 12, 12, 12, 12, 20, 12, 12, 12, 12, 12, 12, 12,
17, 12, 12, 12, 12, 12, 12, 12, 17, 12, 12, 12, 12, 12, 12, 12,
17, 12, 12, 12, 12, 12, 12, 12] 17, 12, 12, 12, 12, 12, 12, 12]
]}, ]},
'maximum': {'subsampling': 0, # "4:4:4" 'maximum': {'subsampling': 0, # "4:4:4"
'quantization': [ 'quantization': [
[ 2, 2, 2, 2, 3, 4, 5, 6, [2, 2, 2, 2, 3, 4, 5, 6,
2, 2, 2, 2, 3, 4, 5, 6, 2, 2, 2, 2, 3, 4, 5, 6,
2, 2, 2, 2, 4, 5, 7, 9, 2, 2, 2, 2, 4, 5, 7, 9,
2, 2, 2, 4, 5, 7, 9, 12, 2, 2, 2, 4, 5, 7, 9, 12,
@ -229,7 +229,7 @@ presets = {
4, 4, 5, 7, 10, 12, 12, 12, 4, 4, 5, 7, 10, 12, 12, 12,
5, 5, 7, 9, 12, 12, 12, 12, 5, 5, 7, 9, 12, 12, 12, 12,
6, 6, 9, 12, 12, 12, 12, 12], 6, 6, 9, 12, 12, 12, 12, 12],
[ 3, 3, 5, 9, 13, 15, 15, 15, [3, 3, 5, 9, 13, 15, 15, 15,
3, 4, 6, 10, 14, 12, 12, 12, 3, 4, 6, 10, 14, 12, 12, 12,
5, 6, 9, 14, 12, 12, 12, 12, 5, 6, 9, 14, 12, 12, 12, 12,
9, 10, 14, 12, 12, 12, 12, 12, 9, 10, 14, 12, 12, 12, 12, 12,
@ -237,5 +237,5 @@ presets = {
15, 12, 12, 12, 12, 12, 12, 12, 15, 12, 12, 12, 12, 12, 12, 12,
15, 12, 12, 12, 12, 12, 12, 12, 15, 12, 12, 12, 12, 12, 12, 12,
15, 12, 12, 12, 12, 12, 12, 12] 15, 12, 12, 12, 12, 12, 12, 12]
]}, ]},
} }

View File

@ -16,11 +16,11 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.2"
import struct import struct
from PIL import Image, ImageFile from PIL import Image, ImageFile
__version__ = "0.2"
def _accept(s): def _accept(s):
return s[:8] == b"\x00\x00\x00\x00\x00\x00\x00\x04" return s[:8] == b"\x00\x00\x00\x00\x00\x00\x00\x04"

View File

@ -17,12 +17,11 @@
# #
__version__ = "0.1"
from PIL import Image, TiffImagePlugin from PIL import Image, TiffImagePlugin
from PIL.OleFileIO import MAGIC, OleFileIO from PIL.OleFileIO import MAGIC, OleFileIO
__version__ = "0.1"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -13,11 +13,12 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.1"
from PIL import Image, ImageFile from PIL import Image, ImageFile
from PIL._binary import i8 from PIL._binary import i8
__version__ = "0.1"
# #
# Bitstream parser # Bitstream parser

View File

@ -18,10 +18,10 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.1"
from PIL import Image, JpegImagePlugin from PIL import Image, JpegImagePlugin
__version__ = "0.1"
def _accept(prefix): def _accept(prefix):
return JpegImagePlugin._accept(prefix) return JpegImagePlugin._accept(prefix)

View File

@ -17,10 +17,10 @@
# #
__version__ = "0.1"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "0.1"
# #
# read MSP files # read MSP files

View File

@ -7,10 +7,10 @@
# Image plugin for Palm pixmap images (output only). # Image plugin for Palm pixmap images (output only).
## ##
__version__ = "1.0"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "1.0"
_Palm8BitColormapValues = ( _Palm8BitColormapValues = (
(255, 255, 255), (255, 204, 255), (255, 153, 255), (255, 102, 255), (255, 255, 255), (255, 204, 255), (255, 153, 255), (255, 102, 255),
(255, 51, 255), (255, 0, 255), (255, 255, 204), (255, 204, 204), (255, 51, 255), (255, 0, 255), (255, 255, 204), (255, 204, 204),
@ -30,15 +30,15 @@ _Palm8BitColormapValues = (
(102, 255, 204), (102, 204, 204), (102, 153, 204), (102, 102, 204), (102, 255, 204), (102, 204, 204), (102, 153, 204), (102, 102, 204),
(102, 51, 204), (102, 0, 204), (102, 255, 153), (102, 204, 153), (102, 51, 204), (102, 0, 204), (102, 255, 153), (102, 204, 153),
(102, 153, 153), (102, 102, 153), (102, 51, 153), (102, 0, 153), (102, 153, 153), (102, 102, 153), (102, 51, 153), (102, 0, 153),
( 51, 255, 255), ( 51, 204, 255), ( 51, 153, 255), ( 51, 102, 255), (51, 255, 255), (51, 204, 255), (51, 153, 255), (51, 102, 255),
( 51, 51, 255), ( 51, 0, 255), ( 51, 255, 204), ( 51, 204, 204), (51, 51, 255), (51, 0, 255), (51, 255, 204), (51, 204, 204),
( 51, 153, 204), ( 51, 102, 204), ( 51, 51, 204), ( 51, 0, 204), (51, 153, 204), (51, 102, 204), (51, 51, 204), (51, 0, 204),
( 51, 255, 153), ( 51, 204, 153), ( 51, 153, 153), ( 51, 102, 153), (51, 255, 153), (51, 204, 153), (51, 153, 153), (51, 102, 153),
( 51, 51, 153), ( 51, 0, 153), ( 0, 255, 255), ( 0, 204, 255), (51, 51, 153), (51, 0, 153), (0, 255, 255), (0, 204, 255),
( 0, 153, 255), ( 0, 102, 255), ( 0, 51, 255), ( 0, 0, 255), (0, 153, 255), (0, 102, 255), (0, 51, 255), (0, 0, 255),
( 0, 255, 204), ( 0, 204, 204), ( 0, 153, 204), ( 0, 102, 204), (0, 255, 204), (0, 204, 204), (0, 153, 204), (0, 102, 204),
( 0, 51, 204), ( 0, 0, 204), ( 0, 255, 153), ( 0, 204, 153), (0, 51, 204), (0, 0, 204), (0, 255, 153), (0, 204, 153),
( 0, 153, 153), ( 0, 102, 153), ( 0, 51, 153), ( 0, 0, 153), (0, 153, 153), (0, 102, 153), (0, 51, 153), (0, 0, 153),
(255, 255, 102), (255, 204, 102), (255, 153, 102), (255, 102, 102), (255, 255, 102), (255, 204, 102), (255, 153, 102), (255, 102, 102),
(255, 51, 102), (255, 0, 102), (255, 255, 51), (255, 204, 51), (255, 51, 102), (255, 0, 102), (255, 255, 51), (255, 204, 51),
(255, 153, 51), (255, 102, 51), (255, 51, 51), (255, 0, 51), (255, 153, 51), (255, 102, 51), (255, 51, 51), (255, 0, 51),
@ -57,25 +57,25 @@ _Palm8BitColormapValues = (
(102, 255, 51), (102, 204, 51), (102, 153, 51), (102, 102, 51), (102, 255, 51), (102, 204, 51), (102, 153, 51), (102, 102, 51),
(102, 51, 51), (102, 0, 51), (102, 255, 0), (102, 204, 0), (102, 51, 51), (102, 0, 51), (102, 255, 0), (102, 204, 0),
(102, 153, 0), (102, 102, 0), (102, 51, 0), (102, 0, 0), (102, 153, 0), (102, 102, 0), (102, 51, 0), (102, 0, 0),
( 51, 255, 102), ( 51, 204, 102), ( 51, 153, 102), ( 51, 102, 102), (51, 255, 102), (51, 204, 102), (51, 153, 102), (51, 102, 102),
( 51, 51, 102), ( 51, 0, 102), ( 51, 255, 51), ( 51, 204, 51), (51, 51, 102), (51, 0, 102), (51, 255, 51), (51, 204, 51),
( 51, 153, 51), ( 51, 102, 51), ( 51, 51, 51), ( 51, 0, 51), (51, 153, 51), (51, 102, 51), (51, 51, 51), (51, 0, 51),
( 51, 255, 0), ( 51, 204, 0), ( 51, 153, 0), ( 51, 102, 0), (51, 255, 0), (51, 204, 0), (51, 153, 0), (51, 102, 0),
( 51, 51, 0), ( 51, 0, 0), ( 0, 255, 102), ( 0, 204, 102), (51, 51, 0), (51, 0, 0), (0, 255, 102), (0, 204, 102),
( 0, 153, 102), ( 0, 102, 102), ( 0, 51, 102), ( 0, 0, 102), (0, 153, 102), (0, 102, 102), (0, 51, 102), (0, 0, 102),
( 0, 255, 51), ( 0, 204, 51), ( 0, 153, 51), ( 0, 102, 51), (0, 255, 51), (0, 204, 51), (0, 153, 51), (0, 102, 51),
( 0, 51, 51), ( 0, 0, 51), ( 0, 255, 0), ( 0, 204, 0), (0, 51, 51), (0, 0, 51), (0, 255, 0), (0, 204, 0),
( 0, 153, 0), ( 0, 102, 0), ( 0, 51, 0), ( 17, 17, 17), (0, 153, 0), (0, 102, 0), (0, 51, 0), (17, 17, 17),
( 34, 34, 34), ( 68, 68, 68), ( 85, 85, 85), (119, 119, 119), (34, 34, 34), (68, 68, 68), (85, 85, 85), (119, 119, 119),
(136, 136, 136), (170, 170, 170), (187, 187, 187), (221, 221, 221), (136, 136, 136), (170, 170, 170), (187, 187, 187), (221, 221, 221),
(238, 238, 238), (192, 192, 192), (128, 0, 0), (128, 0, 128), (238, 238, 238), (192, 192, 192), (128, 0, 0), (128, 0, 128),
( 0, 128, 0), ( 0, 128, 128), ( 0, 0, 0), ( 0, 0, 0), (0, 128, 0), (0, 128, 128), (0, 0, 0), (0, 0, 0),
( 0, 0, 0), ( 0, 0, 0), ( 0, 0, 0), ( 0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
( 0, 0, 0), ( 0, 0, 0), ( 0, 0, 0), ( 0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
( 0, 0, 0), ( 0, 0, 0), ( 0, 0, 0), ( 0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
( 0, 0, 0), ( 0, 0, 0), ( 0, 0, 0), ( 0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
( 0, 0, 0), ( 0, 0, 0), ( 0, 0, 0), ( 0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0),
( 0, 0, 0), ( 0, 0, 0), ( 0, 0, 0), ( 0, 0, 0)) (0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0))
# so build a prototype image to be used for palette resampling # so build a prototype image to be used for palette resampling

View File

@ -15,11 +15,10 @@
# #
__version__ = "0.1"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "0.1"
i8 = _binary.i8 i8 = _binary.i8

View File

@ -20,12 +20,12 @@
# Image plugin for PDF images (output only). # Image plugin for PDF images (output only).
## ##
__version__ = "0.4"
from PIL import Image, ImageFile from PIL import Image, ImageFile
from PIL._binary import i8 from PIL._binary import i8
import io import io
__version__ = "0.4"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -19,10 +19,10 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.1"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "0.1"
# #
# helpers # helpers

View File

@ -33,14 +33,14 @@
from __future__ import print_function from __future__ import print_function
__version__ = "0.9"
import logging import logging
import re import re
import zlib import zlib
from PIL import Image, ImageFile, ImagePalette, _binary from PIL import Image, ImageFile, ImagePalette, _binary
__version__ = "0.9"
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
i8 = _binary.i8 i8 = _binary.i8

View File

@ -15,12 +15,12 @@
# #
__version__ = "0.2"
import string import string
from PIL import Image, ImageFile from PIL import Image, ImageFile
__version__ = "0.2"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -18,11 +18,10 @@
# #
__version__ = "0.2"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "0.2"
i8 = _binary.i8 i8 = _binary.i8
i16 = _binary.i16be i16 = _binary.i16be
i32 = _binary.i32be i32 = _binary.i32be

View File

@ -17,11 +17,10 @@
# #
__version__ = "0.3"
from PIL import Image, ImageFile, ImagePalette, _binary from PIL import Image, ImageFile, ImagePalette, _binary
__version__ = "0.3"
i16 = _binary.i16be i16 = _binary.i16be
i32 = _binary.i32be i32 = _binary.i32be

View File

@ -17,10 +17,10 @@
# #
__version__ = "0.3"
from PIL import Image, ImageFile, ImagePalette, _binary from PIL import Image, ImageFile, ImagePalette, _binary
__version__ = "0.3"
# #
# -------------------------------------------------------------------- # --------------------------------------------------------------------

View File

@ -41,9 +41,6 @@
from __future__ import print_function from __future__ import print_function
__version__ = "1.3.5"
DEBUG = False # Needs to be merged with the new logging approach.
from PIL import Image, ImageFile from PIL import Image, ImageFile
from PIL import ImagePalette from PIL import ImagePalette
from PIL import _binary from PIL import _binary
@ -57,6 +54,9 @@ import itertools
import os import os
import io import io
__version__ = "1.3.5"
DEBUG = False # Needs to be merged with the new logging approach.
# Set these to true to force use of libtiff for reading or writing. # Set these to true to force use of libtiff for reading or writing.
READ_LIBTIFF = False READ_LIBTIFF = False
WRITE_LIBTIFF = False WRITE_LIBTIFF = False
@ -519,7 +519,7 @@ class ImageFileDirectory(collections.MutableMapping):
typ = self.tagtype[tag] typ = self.tagtype[tag]
if DEBUG: if DEBUG:
print ("Tag %s, Type: %s, Value: %s" % (tag, typ, value)) print("Tag %s, Type: %s, Value: %s" % (tag, typ, value))
if typ == 1: if typ == 1:
# byte data # byte data
@ -654,9 +654,9 @@ class TiffImageFile(ImageFile.ImageFile):
self._is_animated = None self._is_animated = None
if DEBUG: if DEBUG:
print ("*** TiffImageFile._open ***") print("*** TiffImageFile._open ***")
print ("- __first:", self.__first) print("- __first:", self.__first)
print ("- ifh: ", ifh) print("- ifh: ", ifh)
# and load the first frame # and load the first frame
self._seek(0) self._seek(0)
@ -702,7 +702,8 @@ class TiffImageFile(ImageFile.ImageFile):
if not self.__next: if not self.__next:
raise EOFError("no more images in TIFF file") raise EOFError("no more images in TIFF file")
if DEBUG: if DEBUG:
print("Seeking to frame %s, on frame %s, __next %s, location: %s" % print("Seeking to frame %s, on frame %s, " +
"__next %s, location: %s" %
(frame, self.__frame, self.__next, self.fp.tell())) (frame, self.__frame, self.__next, self.fp.tell()))
# reset python3 buffered io handle in case fp # reset python3 buffered io handle in case fp
# was passed to libtiff, invalidating the buffer # was passed to libtiff, invalidating the buffer
@ -788,19 +789,19 @@ class TiffImageFile(ImageFile.ImageFile):
# that returns an IOError if there's no underlying fp. Easier to # that returns an IOError if there's no underlying fp. Easier to
# deal with here by reordering. # deal with here by reordering.
if DEBUG: if DEBUG:
print ("have getvalue. just sending in a string from getvalue") print("have getvalue. just sending in a string from getvalue")
n, err = decoder.decode(self.fp.getvalue()) n, err = decoder.decode(self.fp.getvalue())
elif hasattr(self.fp, "fileno"): elif hasattr(self.fp, "fileno"):
# we've got a actual file on disk, pass in the fp. # we've got a actual file on disk, pass in the fp.
if DEBUG: if DEBUG:
print ("have fileno, calling fileno version of the decoder.") print("have fileno, calling fileno version of the decoder.")
self.fp.seek(0) self.fp.seek(0)
# 4 bytes, otherwise the trace might error out # 4 bytes, otherwise the trace might error out
n, err = decoder.decode(b"fpfp") n, err = decoder.decode(b"fpfp")
else: else:
# we have something else. # we have something else.
if DEBUG: if DEBUG:
print ("don't have fileno or getvalue. just reading") print("don't have fileno or getvalue. just reading")
# UNDONE -- so much for that buffer size thing. # UNDONE -- so much for that buffer size thing.
n, err = decoder.decode(self.fp.read()) n, err = decoder.decode(self.fp.read())
@ -980,7 +981,7 @@ class TiffImageFile(ImageFile.ImageFile):
(0, min(y, ysize), w, min(y+h, ysize)), (0, min(y, ysize), w, min(y+h, ysize)),
offsets[i], a)) offsets[i], a))
if DEBUG: if DEBUG:
print ("tiles: ", self.tile) print("tiles: ", self.tile)
y = y + h y = y + h
if y >= self.size[1]: if y >= self.size[1]:
x = y = 0 x = y = 0
@ -1165,8 +1166,8 @@ def _save(im, fp, filename):
if libtiff: if libtiff:
if DEBUG: if DEBUG:
print ("Saving using libtiff encoder") print("Saving using libtiff encoder")
print (ifd.items()) print(ifd.items())
_fp = 0 _fp = 0
if hasattr(fp, "fileno"): if hasattr(fp, "fileno"):
try: try:
@ -1223,7 +1224,7 @@ def _save(im, fp, filename):
atts[k] = v atts[k] = v
if DEBUG: if DEBUG:
print (atts) print(atts)
# libtiff always expects the bytes in native order. # libtiff always expects the bytes in native order.
# we're storing image byte order. So, if the rawmode # we're storing image byte order. So, if the rawmode
@ -1233,7 +1234,7 @@ def _save(im, fp, filename):
rawmode = 'I;16N' rawmode = 'I;16N'
a = (rawmode, compression, _fp, filename, atts) a = (rawmode, compression, _fp, filename, atts)
# print (im.mode, compression, a, im.encoderconfig) # print(im.mode, compression, a, im.encoderconfig)
e = Image._getencoder(im.mode, 'libtiff', a, im.encoderconfig) e = Image._getencoder(im.mode, 'libtiff', a, im.encoderconfig)
e.setimage(im.im, (0, 0)+im.size) e.setimage(im.im, (0, 0)+im.size)
while True: while True:

View File

@ -15,10 +15,10 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.2"
from PIL import Image, ImageFile, _binary from PIL import Image, ImageFile, _binary
__version__ = "0.2"
_handler = None _handler = None
if str != bytes: if str != bytes:

View File

@ -17,10 +17,10 @@
# FIXME: make save work (this requires quantization support) # FIXME: make save work (this requires quantization support)
# #
__version__ = "0.1"
from PIL import Image, ImageFile, ImagePalette, _binary from PIL import Image, ImageFile, ImagePalette, _binary
__version__ = "0.1"
o8 = _binary.o8 o8 = _binary.o8
# standard color palette for thumbnails (RGB332) # standard color palette for thumbnails (RGB332)

View File

@ -19,11 +19,11 @@
# See the README file for information on usage and redistribution. # See the README file for information on usage and redistribution.
# #
__version__ = "0.6"
import re import re
from PIL import Image, ImageFile from PIL import Image, ImageFile
__version__ = "0.6"
# XBM header # XBM header
xbm_head = re.compile( xbm_head = re.compile(
b"\s*#define[ \t]+.*_width[ \t]+(?P<width>[0-9]+)[\r\n]+" b"\s*#define[ \t]+.*_width[ \t]+(?P<width>[0-9]+)[\r\n]+"

View File

@ -15,13 +15,12 @@
# #
__version__ = "0.2"
import re import re
from PIL import Image, ImageFile, ImagePalette from PIL import Image, ImageFile, ImagePalette
from PIL._binary import i8, o8 from PIL._binary import i8, o8
__version__ = "0.2"
# XPM header # XPM header
xpm_head = re.compile(b"\"([0-9]*) ([0-9]*) ([0-9]*) ([0-9]*)") xpm_head = re.compile(b"\"([0-9]*) ([0-9]*) ([0-9]*) ([0-9]*)")

View File

@ -12,8 +12,6 @@
from __future__ import print_function from __future__ import print_function
VERSION = "0.4"
import glob import glob
import sys import sys
@ -21,6 +19,8 @@ import sys
from PIL import BdfFontFile from PIL import BdfFontFile
from PIL import PcfFontFile from PIL import PcfFontFile
VERSION = "0.4"
if len(sys.argv) <= 1: if len(sys.argv) <= 1:
print("PILFONT", VERSION, "-- PIL font compiler.") print("PILFONT", VERSION, "-- PIL font compiler.")
print() print()

View File

@ -1,9 +1,9 @@
import sys
sys.path.insert(0, ".")
import helper import helper
import timeit import timeit
import sys
sys.path.insert(0, ".")
def bench(mode): def bench(mode):
im = helper.hopper(mode) im = helper.hopper(mode)

View File

@ -1,11 +1,12 @@
from __future__ import print_function from __future__ import print_function
import sys
sys.path.insert(0, ".")
import glob import glob
import os import os
import traceback import traceback
import sys
sys.path.insert(0, ".")
for file in glob.glob("PIL/*.py"): for file in glob.glob("PIL/*.py"):
module = os.path.basename(file)[:-3] module = os.path.basename(file)[:-3]
try: try:

View File

@ -1,9 +1,9 @@
import sys
sys.path.insert(0, ".")
from PIL import Image from PIL import Image
from PIL import ImageCms from PIL import ImageCms
import sys
sys.path.insert(0, ".")
try: try:
filename = sys.argv[1] filename = sys.argv[1]
except IndexError: except IndexError:

View File

@ -1,10 +1,11 @@
from __future__ import print_function from __future__ import print_function
import sys
sys.path.insert(0, ".")
from PIL import Image from PIL import Image
from PIL import ImageMath from PIL import ImageMath
import sys
sys.path.insert(0, ".")
try: try:
filename = sys.argv[1] filename = sys.argv[1]
except IndexError: except IndexError:

View File

@ -88,7 +88,6 @@ class TestFileTiff(PillowTestCase):
self.assertRaises(SyntaxError, self.assertRaises(SyntaxError,
lambda: TiffImagePlugin.TiffImageFile(invalid_file)) lambda: TiffImagePlugin.TiffImageFile(invalid_file))
def test_bad_exif(self): def test_bad_exif(self):
try: try:
Image.open('Tests/images/hopper_bad_exif.jpg')._getexif() Image.open('Tests/images/hopper_bad_exif.jpg')._getexif()

View File

@ -5,14 +5,14 @@ from PIL import ImageColor
from PIL import ImageDraw from PIL import ImageDraw
import os.path import os.path
import sys
BLACK = (0, 0, 0) BLACK = (0, 0, 0)
WHITE = (255, 255, 255) WHITE = (255, 255, 255)
GRAY = (190, 190, 190) GRAY = (190, 190, 190)
DEFAULT_MODE = 'RGB' DEFAULT_MODE = 'RGB'
IMAGES_PATH = os.path.join('Tests', 'images', 'imagedraw') IMAGES_PATH = os.path.join('Tests', 'images', 'imagedraw')
import sys
# Image size # Image size
W, H = 100, 100 W, H = 100, 100

View File

@ -94,7 +94,7 @@ endlocal
def cp_tk(ver_85, ver_86): def cp_tk(ver_85, ver_86):
versions = {'ver_85':ver_85, 'ver_86':ver_86} versions = {'ver_85': ver_85, 'ver_86': ver_86}
return r""" return r"""
mkdir %%INCLIB%%\tcl85\include\X11 mkdir %%INCLIB%%\tcl85\include\X11
copy /Y /B %%BUILD%%\tcl%(ver_85)s\generic\*.h %%INCLIB%%\tcl85\include\ copy /Y /B %%BUILD%%\tcl%(ver_85)s\generic\*.h %%INCLIB%%\tcl85\include\
@ -308,7 +308,7 @@ def add_compiler(compiler):
mkdirs() mkdirs()
fetch_libs() fetch_libs()
# extract_binlib() # extract_binlib()
script = [header(), cp_tk(libs['tk-8.5']['version'],libs['tk-8.6']['version'] )] script = [header(), cp_tk(libs['tk-8.5']['version'], libs['tk-8.6']['version'])]
if 'PYTHON' in os.environ: if 'PYTHON' in os.environ:

View File

@ -2,9 +2,9 @@ import os
SF_MIRROR = 'http://iweb.dl.sourceforge.net' SF_MIRROR = 'http://iweb.dl.sourceforge.net'
pythons = {#'26': 7, pythons = { # '26': 7,
'27': 7, '27': 7,
#'32': 7, # '32': 7,
'33': 7.1, '33': 7.1,
'34': 7.1} '34': 7.1}
@ -46,7 +46,7 @@ libs = {
'url': SF_MIRROR+'/project/tcl/Tcl/8.5.18/tk8518-src.zip', 'url': SF_MIRROR+'/project/tcl/Tcl/8.5.18/tk8518-src.zip',
'hash': 'sha1:273f55148777413774aa722ecad25cabda1e31ae', 'hash': 'sha1:273f55148777413774aa722ecad25cabda1e31ae',
'dir': '', 'dir': '',
'version':'8.5.18', 'version': '8.5.18',
}, },
'tcl-8.6': { 'tcl-8.6': {
'url': SF_MIRROR+'/project/tcl/Tcl/8.6.4/tcl864-src.zip', 'url': SF_MIRROR+'/project/tcl/Tcl/8.6.4/tcl864-src.zip',
@ -57,7 +57,7 @@ libs = {
'url': SF_MIRROR+'/project/tcl/Tcl/8.6.4/tk864-src.zip', 'url': SF_MIRROR+'/project/tcl/Tcl/8.6.4/tk864-src.zip',
'hash': 'md5:111d45061a69e7f5250b6ec8ca7c4f35', 'hash': 'md5:111d45061a69e7f5250b6ec8ca7c4f35',
'dir': '', 'dir': '',
'version':'8.6.4', 'version': '8.6.4',
}, },
'webp': { 'webp': {
'url': 'http://downloads.webmproject.org/releases/webp/libwebp-0.4.3.tar.gz', 'url': 'http://downloads.webmproject.org/releases/webp/libwebp-0.4.3.tar.gz',