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
import math
__version__ = "0.7"
i8 = _binary.i8
i16 = _binary.i16le

View File

@ -17,10 +17,9 @@
#
__version__ = "0.1"
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.
#
__version__ = "0.2"
from PIL import Image, _binary
from PIL.PcxImagePlugin import PcxImageFile
__version__ = "0.2"
MAGIC = 0x3ADE68B1 # QUIZ: what's this value, then?
i32 = _binary.i32le

View File

@ -20,12 +20,13 @@
# See the README file for information on usage and redistribution.
#
__version__ = "0.5"
import re
import io
import sys
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]*$")
gs_windows_binary = None
import sys
if sys.platform.startswith('win'):
import shutil
if hasattr(shutil, 'which'):
@ -187,7 +187,8 @@ class PSFile(object):
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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -33,7 +33,7 @@ import io
import logging
import os
import sys
import traceback
# import traceback
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
# default to /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':
dirs += ['/Library/Fonts', '/System/Library/Fonts',
os.path.expanduser('~/Library/Fonts')]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,11 +16,11 @@
# See the README file for information on usage and redistribution.
#
__version__ = "0.2"
import struct
from PIL import Image, ImageFile
__version__ = "0.2"
def _accept(s):
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.OleFileIO import MAGIC, OleFileIO
__version__ = "0.1"
#
# --------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

@ -7,10 +7,10 @@
# Image plugin for Palm pixmap images (output only).
##
__version__ = "1.0"
from PIL import Image, ImageFile, _binary
__version__ = "1.0"
_Palm8BitColormapValues = (
(255, 255, 255), (255, 204, 255), (255, 153, 255), (255, 102, 255),
(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, 51, 204), (102, 0, 204), (102, 255, 153), (102, 204, 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, 51, 255), ( 51, 0, 255), ( 51, 255, 204), ( 51, 204, 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, 51, 153), ( 51, 0, 153), ( 0, 255, 255), ( 0, 204, 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, 51, 204), ( 0, 0, 204), ( 0, 255, 153), ( 0, 204, 153),
( 0, 153, 153), ( 0, 102, 153), ( 0, 51, 153), ( 0, 0, 153),
(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, 153, 204), (51, 102, 204), (51, 51, 204), (51, 0, 204),
(51, 255, 153), (51, 204, 153), (51, 153, 153), (51, 102, 153),
(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, 255, 204), (0, 204, 204), (0, 153, 204), (0, 102, 204),
(0, 51, 204), (0, 0, 204), (0, 255, 153), (0, 204, 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, 51, 102), (255, 0, 102), (255, 255, 51), (255, 204, 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, 51, 51), (102, 0, 51), (102, 255, 0), (102, 204, 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, 51, 102), ( 51, 0, 102), ( 51, 255, 51), ( 51, 204, 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, 51, 0), ( 51, 0, 0), ( 0, 255, 102), ( 0, 204, 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, 51, 51), ( 0, 0, 51), ( 0, 255, 0), ( 0, 204, 0),
( 0, 153, 0), ( 0, 102, 0), ( 0, 51, 0), ( 17, 17, 17),
( 34, 34, 34), ( 68, 68, 68), ( 85, 85, 85), (119, 119, 119),
(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, 153, 51), (51, 102, 51), (51, 51, 51), (51, 0, 51),
(51, 255, 0), (51, 204, 0), (51, 153, 0), (51, 102, 0),
(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, 255, 51), (0, 204, 51), (0, 153, 51), (0, 102, 51),
(0, 51, 51), (0, 0, 51), (0, 255, 0), (0, 204, 0),
(0, 153, 0), (0, 102, 0), (0, 51, 0), (17, 17, 17),
(34, 34, 34), (68, 68, 68), (85, 85, 85), (119, 119, 119),
(136, 136, 136), (170, 170, 170), (187, 187, 187), (221, 221, 221),
(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, 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, 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))
# 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
__version__ = "0.1"
i8 = _binary.i8

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -41,9 +41,6 @@
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 ImagePalette
from PIL import _binary
@ -57,6 +54,9 @@ import itertools
import os
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.
READ_LIBTIFF = False
WRITE_LIBTIFF = False
@ -519,7 +519,7 @@ class ImageFileDirectory(collections.MutableMapping):
typ = self.tagtype[tag]
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:
# byte data
@ -654,9 +654,9 @@ class TiffImageFile(ImageFile.ImageFile):
self._is_animated = None
if DEBUG:
print ("*** TiffImageFile._open ***")
print ("- __first:", self.__first)
print ("- ifh: ", ifh)
print("*** TiffImageFile._open ***")
print("- __first:", self.__first)
print("- ifh: ", ifh)
# and load the first frame
self._seek(0)
@ -702,7 +702,8 @@ class TiffImageFile(ImageFile.ImageFile):
if not self.__next:
raise EOFError("no more images in TIFF file")
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()))
# reset python3 buffered io handle in case fp
# 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
# deal with here by reordering.
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())
elif hasattr(self.fp, "fileno"):
# we've got a actual file on disk, pass in the fp.
if DEBUG:
print ("have fileno, calling fileno version of the decoder.")
print("have fileno, calling fileno version of the decoder.")
self.fp.seek(0)
# 4 bytes, otherwise the trace might error out
n, err = decoder.decode(b"fpfp")
else:
# we have something else.
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.
n, err = decoder.decode(self.fp.read())
@ -980,7 +981,7 @@ class TiffImageFile(ImageFile.ImageFile):
(0, min(y, ysize), w, min(y+h, ysize)),
offsets[i], a))
if DEBUG:
print ("tiles: ", self.tile)
print("tiles: ", self.tile)
y = y + h
if y >= self.size[1]:
x = y = 0
@ -1165,8 +1166,8 @@ def _save(im, fp, filename):
if libtiff:
if DEBUG:
print ("Saving using libtiff encoder")
print (ifd.items())
print("Saving using libtiff encoder")
print(ifd.items())
_fp = 0
if hasattr(fp, "fileno"):
try:
@ -1223,7 +1224,7 @@ def _save(im, fp, filename):
atts[k] = v
if DEBUG:
print (atts)
print(atts)
# libtiff always expects the bytes in native order.
# we're storing image byte order. So, if the rawmode
@ -1233,7 +1234,7 @@ def _save(im, fp, filename):
rawmode = 'I;16N'
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.setimage(im.im, (0, 0)+im.size)
while True:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -94,7 +94,7 @@ endlocal
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"""
mkdir %%INCLIB%%\tcl85\include\X11
copy /Y /B %%BUILD%%\tcl%(ver_85)s\generic\*.h %%INCLIB%%\tcl85\include\
@ -308,7 +308,7 @@ def add_compiler(compiler):
mkdirs()
fetch_libs()
# 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:

View File

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