mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Merge branch 'cleanup' of https://github.com/wiredfool/Pillow into wiredfool-cleanup
Conflicts: Tests/test_file_jpeg2k.py Tests/test_image_transform.py Tests/test_imagesequence.py
This commit is contained in:
commit
1633ffa878
|
@ -370,7 +370,7 @@ class ArgStream(ChunkStream):
|
||||||
im1 = im1.chop_add_modulo(im0.crop(bbox))
|
im1 = im1.chop_add_modulo(im0.crop(bbox))
|
||||||
im0.paste(im1, bbox)
|
im0.paste(im1, bbox)
|
||||||
|
|
||||||
self.count = self.count - 1
|
self.count -= 1
|
||||||
|
|
||||||
if self.count == 0 and self.show:
|
if self.count == 0 and self.show:
|
||||||
self.im = self.images[self.id]
|
self.im = self.images[self.id]
|
||||||
|
|
|
@ -128,5 +128,5 @@ class BdfFontFile(FontFile.FontFile):
|
||||||
if not c:
|
if not c:
|
||||||
break
|
break
|
||||||
id, ch, (xy, dst, src), im = c
|
id, ch, (xy, dst, src), im = c
|
||||||
if ch >= 0 and ch < len(self.glyph):
|
if 0 <= ch < len(self.glyph):
|
||||||
self.glyph[ch] = xy, dst, src, im
|
self.glyph[ch] = xy, dst, src, im
|
||||||
|
|
|
@ -104,7 +104,7 @@ def Ghostscript(tile, size, fp, scale=1):
|
||||||
s = fp.read(min(lengthfile, 100*1024))
|
s = fp.read(min(lengthfile, 100*1024))
|
||||||
if not s:
|
if not s:
|
||||||
break
|
break
|
||||||
lengthfile = lengthfile - len(s)
|
length -= len(s)
|
||||||
f.write(s)
|
f.write(s)
|
||||||
|
|
||||||
# Build ghostscript command
|
# Build ghostscript command
|
||||||
|
@ -161,7 +161,7 @@ class PSFile:
|
||||||
def tell(self):
|
def tell(self):
|
||||||
pos = self.fp.tell()
|
pos = self.fp.tell()
|
||||||
if self.char:
|
if self.char:
|
||||||
pos = pos - 1
|
pos -= 1
|
||||||
return pos
|
return pos
|
||||||
def readline(self):
|
def readline(self):
|
||||||
s = b""
|
s = b""
|
||||||
|
|
|
@ -63,15 +63,12 @@ TAGS = {
|
||||||
0x0201: "JpegIFOffset",
|
0x0201: "JpegIFOffset",
|
||||||
0x0202: "JpegIFByteCount",
|
0x0202: "JpegIFByteCount",
|
||||||
0x0211: "YCbCrCoefficients",
|
0x0211: "YCbCrCoefficients",
|
||||||
0x0211: "YCbCrCoefficients",
|
|
||||||
0x0212: "YCbCrSubSampling",
|
0x0212: "YCbCrSubSampling",
|
||||||
0x0213: "YCbCrPositioning",
|
0x0213: "YCbCrPositioning",
|
||||||
0x0213: "YCbCrPositioning",
|
|
||||||
0x0214: "ReferenceBlackWhite",
|
|
||||||
0x0214: "ReferenceBlackWhite",
|
0x0214: "ReferenceBlackWhite",
|
||||||
0x1000: "RelatedImageFileFormat",
|
0x1000: "RelatedImageFileFormat",
|
||||||
0x1001: "RelatedImageLength",
|
0x1001: "RelatedImageLength", # FIXME / Dictionary contains duplicate keys
|
||||||
0x1001: "RelatedImageWidth",
|
0x1001: "RelatedImageWidth", # FIXME \ Dictionary contains duplicate keys
|
||||||
0x828d: "CFARepeatPatternDim",
|
0x828d: "CFARepeatPatternDim",
|
||||||
0x828e: "CFAPattern",
|
0x828e: "CFAPattern",
|
||||||
0x828f: "BatteryLevel",
|
0x828f: "BatteryLevel",
|
||||||
|
|
|
@ -105,7 +105,7 @@ class FliImageFile(ImageFile.ImageFile):
|
||||||
g = i8(s[n+1]) << shift
|
g = i8(s[n+1]) << shift
|
||||||
b = i8(s[n+2]) << shift
|
b = i8(s[n+2]) << shift
|
||||||
palette[i] = (r, g, b)
|
palette[i] = (r, g, b)
|
||||||
i = i + 1
|
i += 1
|
||||||
|
|
||||||
def seek(self, frame):
|
def seek(self, frame):
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ def puti16(fp, values):
|
||||||
# write network order (big-endian) 16-bit sequence
|
# write network order (big-endian) 16-bit sequence
|
||||||
for v in values:
|
for v in values:
|
||||||
if v < 0:
|
if v < 0:
|
||||||
v = v + 65536
|
v += 65536
|
||||||
fp.write(_binary.o16be(v))
|
fp.write(_binary.o16be(v))
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -63,7 +63,7 @@ class FontFile:
|
||||||
h = max(h, src[3] - src[1])
|
h = max(h, src[3] - src[1])
|
||||||
w = w + (src[2] - src[0])
|
w = w + (src[2] - src[0])
|
||||||
if w > WIDTH:
|
if w > WIDTH:
|
||||||
lines = lines + 1
|
lines += 1
|
||||||
w = (src[2] - src[0])
|
w = (src[2] - src[0])
|
||||||
maxwidth = max(maxwidth, w)
|
maxwidth = max(maxwidth, w)
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ class FpxImageFile(ImageFile.ImageFile):
|
||||||
i = 1
|
i = 1
|
||||||
while size > 64:
|
while size > 64:
|
||||||
size = size / 2
|
size = size / 2
|
||||||
i = i + 1
|
i += 1
|
||||||
self.maxid = i - 1
|
self.maxid = i - 1
|
||||||
|
|
||||||
# mode. instead of using a single field for this, flashpix
|
# mode. instead of using a single field for this, flashpix
|
||||||
|
|
|
@ -68,7 +68,7 @@ class GradientFile:
|
||||||
x = i / float(entries-1)
|
x = i / float(entries-1)
|
||||||
|
|
||||||
while x1 < x:
|
while x1 < x:
|
||||||
ix = ix + 1
|
ix += 1
|
||||||
x0, x1, xm, rgb0, rgb1, segment = self.gradient[ix]
|
x0, x1, xm, rgb0, rgb1, segment = self.gradient[ix]
|
||||||
|
|
||||||
w = x1 - x0
|
w = x1 - x0
|
||||||
|
|
|
@ -52,7 +52,7 @@ class GimpPaletteFile:
|
||||||
if 0 <= i <= 255:
|
if 0 <= i <= 255:
|
||||||
self.palette[i] = o8(v[0]) + o8(v[1]) + o8(v[2])
|
self.palette[i] = o8(v[0]) + o8(v[1]) + o8(v[2])
|
||||||
|
|
||||||
i = i + 1
|
i += 1
|
||||||
|
|
||||||
self.palette = b"".join(self.palette)
|
self.palette = b"".join(self.palette)
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ def read_32(fobj, start_length, size):
|
||||||
else:
|
else:
|
||||||
blocksize = byte + 1
|
blocksize = byte + 1
|
||||||
data.append(fobj.read(blocksize))
|
data.append(fobj.read(blocksize))
|
||||||
bytesleft = bytesleft - blocksize
|
bytesleft -= blocksize
|
||||||
if bytesleft <= 0:
|
if bytesleft <= 0:
|
||||||
break
|
break
|
||||||
if bytesleft != 0:
|
if bytesleft != 0:
|
||||||
|
@ -179,11 +179,11 @@ class IcnsFile:
|
||||||
i = HEADERSIZE
|
i = HEADERSIZE
|
||||||
while i < filesize:
|
while i < filesize:
|
||||||
sig, blocksize = nextheader(fobj)
|
sig, blocksize = nextheader(fobj)
|
||||||
i = i + HEADERSIZE
|
i += HEADERSIZE
|
||||||
blocksize = blocksize - HEADERSIZE
|
blocksize -= HEADERSIZE
|
||||||
dct[sig] = (i, blocksize)
|
dct[sig] = (i, blocksize)
|
||||||
fobj.seek(blocksize, 1)
|
fobj.seek(blocksize, 1)
|
||||||
i = i + blocksize
|
i += blocksize
|
||||||
|
|
||||||
def itersizes(self):
|
def itersizes(self):
|
||||||
sizes = []
|
sizes = []
|
||||||
|
|
|
@ -182,7 +182,7 @@ class ImImageFile(ImageFile.ImageFile):
|
||||||
self.info[k] = v
|
self.info[k] = v
|
||||||
|
|
||||||
if k in TAGS:
|
if k in TAGS:
|
||||||
n = n + 1
|
n += 1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
|
|
@ -448,7 +448,7 @@ def _getscaleoffset(expr):
|
||||||
(a, b, c) = data # simplified syntax
|
(a, b, c) = data # simplified syntax
|
||||||
if (a is stub and b == "__mul__" and isinstance(c, numbers.Number)):
|
if (a is stub and b == "__mul__" and isinstance(c, numbers.Number)):
|
||||||
return c, 0.0
|
return c, 0.0
|
||||||
if (a is stub and b == "__add__" and isinstance(c, numbers.Number)):
|
if a is stub and b == "__add__" and isinstance(c, numbers.Number):
|
||||||
return 1.0, c
|
return 1.0, c
|
||||||
except TypeError:
|
except TypeError:
|
||||||
pass
|
pass
|
||||||
|
@ -2074,7 +2074,6 @@ def frombuffer(mode, size, data, decoder_name="raw", *args):
|
||||||
|
|
||||||
.. versionadded:: 1.1.4
|
.. versionadded:: 1.1.4
|
||||||
"""
|
"""
|
||||||
"Load image from bytes or buffer"
|
|
||||||
|
|
||||||
# may pass tuple instead of argument list
|
# may pass tuple instead of argument list
|
||||||
if len(args) == 1 and isinstance(args[0], tuple):
|
if len(args) == 1 and isinstance(args[0], tuple):
|
||||||
|
|
|
@ -502,5 +502,5 @@ def _safe_read(fp, size):
|
||||||
if not block:
|
if not block:
|
||||||
break
|
break
|
||||||
data.append(block)
|
data.append(block)
|
||||||
size = size - len(block)
|
size -= len(block)
|
||||||
return b"".join(data)
|
return b"".join(data)
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from PIL import _imagingmath
|
from PIL import _imagingmath
|
||||||
import sys
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import builtins
|
import builtins
|
||||||
|
|
|
@ -94,7 +94,7 @@ def autocontrast(image, cutoff=0, ignore=None):
|
||||||
cut = cut - h[lo]
|
cut = cut - h[lo]
|
||||||
h[lo] = 0
|
h[lo] = 0
|
||||||
else:
|
else:
|
||||||
h[lo] = h[lo] - cut
|
h[lo] -= cut
|
||||||
cut = 0
|
cut = 0
|
||||||
if cut <= 0:
|
if cut <= 0:
|
||||||
break
|
break
|
||||||
|
@ -105,7 +105,7 @@ def autocontrast(image, cutoff=0, ignore=None):
|
||||||
cut = cut - h[hi]
|
cut = cut - h[hi]
|
||||||
h[hi] = 0
|
h[hi] = 0
|
||||||
else:
|
else:
|
||||||
h[hi] = h[hi] - cut
|
h[hi] -= cut
|
||||||
cut = 0
|
cut = 0
|
||||||
if cut <= 0:
|
if cut <= 0:
|
||||||
break
|
break
|
||||||
|
|
|
@ -17,7 +17,7 @@ from __future__ import print_function
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import os, sys
|
import os, sys
|
||||||
|
|
||||||
if(sys.version_info >= (3, 3)):
|
if sys.version_info >= (3, 3):
|
||||||
from shlex import quote
|
from shlex import quote
|
||||||
else:
|
else:
|
||||||
from pipes import quote
|
from pipes import quote
|
||||||
|
@ -160,7 +160,7 @@ else:
|
||||||
# imagemagick's display command instead.
|
# imagemagick's display command instead.
|
||||||
command = executable = "xv"
|
command = executable = "xv"
|
||||||
if title:
|
if title:
|
||||||
command = command + " -name %s" % quote(title)
|
command += " -name %s" % quote(title)
|
||||||
return command, executable
|
return command, executable
|
||||||
|
|
||||||
if which("xv"):
|
if which("xv"):
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
# See the README file for information on usage and redistribution.
|
# See the README file for information on usage and redistribution.
|
||||||
#
|
#
|
||||||
|
|
||||||
from PIL import Image
|
|
||||||
import operator, math
|
import operator, math
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
|
|
||||||
|
@ -81,7 +80,7 @@ class Stat:
|
||||||
for i in range(0, len(self.h), 256):
|
for i in range(0, len(self.h), 256):
|
||||||
sum = 0.0
|
sum = 0.0
|
||||||
for j in range(256):
|
for j in range(256):
|
||||||
sum = sum + j * self.h[i+j]
|
sum += j * self.h[i + j]
|
||||||
v.append(sum)
|
v.append(sum)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ class Stat:
|
||||||
for i in range(0, len(self.h), 256):
|
for i in range(0, len(self.h), 256):
|
||||||
sum2 = 0.0
|
sum2 = 0.0
|
||||||
for j in range(256):
|
for j in range(256):
|
||||||
sum2 = sum2 + (j ** 2) * float(self.h[i+j])
|
sum2 += (j ** 2) * float(self.h[i + j])
|
||||||
v.append(sum2)
|
v.append(sum2)
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ class IptcImageFile(ImageFile.ImageFile):
|
||||||
break
|
break
|
||||||
if s != sz:
|
if s != sz:
|
||||||
return 0
|
return 0
|
||||||
y = y + 1
|
y += 1
|
||||||
return y == size[1]
|
return y == size[1]
|
||||||
|
|
||||||
def _open(self):
|
def _open(self):
|
||||||
|
@ -187,7 +187,7 @@ class IptcImageFile(ImageFile.ImageFile):
|
||||||
if not s:
|
if not s:
|
||||||
break
|
break
|
||||||
o.write(s)
|
o.write(s)
|
||||||
size = size - len(s)
|
size -= len(s)
|
||||||
o.close()
|
o.close()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -235,26 +235,26 @@ def getiptcinfo(im):
|
||||||
# parse the image resource block
|
# parse the image resource block
|
||||||
offset = 0
|
offset = 0
|
||||||
while app[offset:offset+4] == "8BIM":
|
while app[offset:offset+4] == "8BIM":
|
||||||
offset = offset + 4
|
offset += 4
|
||||||
# resource code
|
# resource code
|
||||||
code = JpegImagePlugin.i16(app, offset)
|
code = JpegImagePlugin.i16(app, offset)
|
||||||
offset = offset + 2
|
offset += 2
|
||||||
# resource name (usually empty)
|
# resource name (usually empty)
|
||||||
name_len = i8(app[offset])
|
name_len = i8(app[offset])
|
||||||
name = app[offset+1:offset+1+name_len]
|
name = app[offset+1:offset+1+name_len]
|
||||||
offset = 1 + offset + name_len
|
offset = 1 + offset + name_len
|
||||||
if offset & 1:
|
if offset & 1:
|
||||||
offset = offset + 1
|
offset += 1
|
||||||
# resource data block
|
# resource data block
|
||||||
size = JpegImagePlugin.i32(app, offset)
|
size = JpegImagePlugin.i32(app, offset)
|
||||||
offset = offset + 4
|
offset += 4
|
||||||
if code == 0x0404:
|
if code == 0x0404:
|
||||||
# 0x0404 contains IPTC/NAA data
|
# 0x0404 contains IPTC/NAA data
|
||||||
data = app[offset:offset+size]
|
data = app[offset:offset+size]
|
||||||
break
|
break
|
||||||
offset = offset + size
|
offset = offset + size
|
||||||
if offset & 1:
|
if offset & 1:
|
||||||
offset = offset + 1
|
offset += 1
|
||||||
except (AttributeError, KeyError):
|
except (AttributeError, KeyError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ def _parse_codestream(fp):
|
||||||
elif csiz == 3:
|
elif csiz == 3:
|
||||||
mode = 'RGB'
|
mode = 'RGB'
|
||||||
elif csiz == 4:
|
elif csiz == 4:
|
||||||
mode == 'RGBA'
|
mode = 'RGBA'
|
||||||
else:
|
else:
|
||||||
mode = None
|
mode = None
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ def _parse_jp2_header(fp):
|
||||||
if nc == 3:
|
if nc == 3:
|
||||||
mode = 'RGB'
|
mode = 'RGB'
|
||||||
elif nc == 4:
|
elif nc == 4:
|
||||||
mode == 'RGBA'
|
mode = 'RGBA'
|
||||||
break
|
break
|
||||||
|
|
||||||
return (size, mode)
|
return (size, mode)
|
||||||
|
|
|
@ -561,8 +561,8 @@ def _save(im, fp, filename):
|
||||||
i = 1
|
i = 1
|
||||||
for marker in markers:
|
for marker in markers:
|
||||||
size = struct.pack(">H", 2 + ICC_OVERHEAD_LEN + len(marker))
|
size = struct.pack(">H", 2 + ICC_OVERHEAD_LEN + len(marker))
|
||||||
extra = extra + (b"\xFF\xE2" + size + b"ICC_PROFILE\0" + o8(i) + o8(len(markers)) + marker)
|
extra += b"\xFF\xE2" + size + b"ICC_PROFILE\0" + o8(i) + o8(len(markers)) + marker
|
||||||
i = i + 1
|
i += 1
|
||||||
|
|
||||||
# get keyword arguments
|
# get keyword arguments
|
||||||
im.encoderconfig = (
|
im.encoderconfig = (
|
||||||
|
|
|
@ -38,13 +38,13 @@ class BitStream:
|
||||||
self.bits = 0
|
self.bits = 0
|
||||||
continue
|
continue
|
||||||
self.bitbuffer = (self.bitbuffer << 8) + c
|
self.bitbuffer = (self.bitbuffer << 8) + c
|
||||||
self.bits = self.bits + 8
|
self.bits += 8
|
||||||
return self.bitbuffer >> (self.bits - bits) & (1 << bits) - 1
|
return self.bitbuffer >> (self.bits - bits) & (1 << bits) - 1
|
||||||
|
|
||||||
def skip(self, bits):
|
def skip(self, bits):
|
||||||
while self.bits < bits:
|
while self.bits < bits:
|
||||||
self.bitbuffer = (self.bitbuffer << 8) + i8(self.fp.read(1))
|
self.bitbuffer = (self.bitbuffer << 8) + i8(self.fp.read(1))
|
||||||
self.bits = self.bits + 8
|
self.bits += 8
|
||||||
self.bits = self.bits - bits
|
self.bits = self.bits - bits
|
||||||
|
|
||||||
def read(self, bits):
|
def read(self, bits):
|
||||||
|
|
|
@ -172,21 +172,21 @@ def _save(im, fp, filename, check=0):
|
||||||
cols = im.size[0]
|
cols = im.size[0]
|
||||||
rows = im.size[1]
|
rows = im.size[1]
|
||||||
|
|
||||||
rowbytes = ((cols + (16//bpp - 1)) / (16 // bpp)) * 2;
|
rowbytes = ((cols + (16//bpp - 1)) / (16 // bpp)) * 2
|
||||||
transparent_index = 0
|
transparent_index = 0
|
||||||
compression_type = _COMPRESSION_TYPES["none"]
|
compression_type = _COMPRESSION_TYPES["none"]
|
||||||
|
|
||||||
flags = 0;
|
flags = 0
|
||||||
if im.mode == "P" and "custom-colormap" in im.info:
|
if im.mode == "P" and "custom-colormap" in im.info:
|
||||||
flags = flags & _FLAGS["custom-colormap"]
|
flags = flags & _FLAGS["custom-colormap"]
|
||||||
colormapsize = 4 * 256 + 2;
|
colormapsize = 4 * 256 + 2
|
||||||
colormapmode = im.palette.mode
|
colormapmode = im.palette.mode
|
||||||
colormap = im.getdata().getpalette()
|
colormap = im.getdata().getpalette()
|
||||||
else:
|
else:
|
||||||
colormapsize = 0
|
colormapsize = 0
|
||||||
|
|
||||||
if "offset" in im.info:
|
if "offset" in im.info:
|
||||||
offset = (rowbytes * rows + 16 + 3 + colormapsize) // 4;
|
offset = (rowbytes * rows + 16 + 3 + colormapsize) // 4
|
||||||
else:
|
else:
|
||||||
offset = 0
|
offset = 0
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ def _save(im, fp, filename, check=0):
|
||||||
# bytes per plane
|
# bytes per plane
|
||||||
stride = (im.size[0] * bits + 7) // 8
|
stride = (im.size[0] * bits + 7) // 8
|
||||||
# stride should be even
|
# stride should be even
|
||||||
stride = stride + (stride % 2)
|
stride += stride % 2
|
||||||
# Stride needs to be kept in sync with the PcxEncode.c version.
|
# Stride needs to be kept in sync with the PcxEncode.c version.
|
||||||
# Ideally it should be passed in in the state, but the bytes value
|
# Ideally it should be passed in in the state, but the bytes value
|
||||||
# gets overwritten.
|
# gets overwritten.
|
||||||
|
|
|
@ -108,8 +108,8 @@ def _save(im, fp, filename):
|
||||||
r = i8(palette[i*3])
|
r = i8(palette[i*3])
|
||||||
g = i8(palette[i*3+1])
|
g = i8(palette[i*3+1])
|
||||||
b = i8(palette[i*3+2])
|
b = i8(palette[i*3+2])
|
||||||
colorspace = colorspace + "%02x%02x%02x " % (r, g, b)
|
colorspace += "%02x%02x%02x " % (r, g, b)
|
||||||
colorspace = colorspace + "> ]"
|
colorspace += "> ]"
|
||||||
procset = "/ImageI" # indexed color
|
procset = "/ImageI" # indexed color
|
||||||
elif im.mode == "RGB":
|
elif im.mode == "RGB":
|
||||||
filter = "/DCTDecode"
|
filter = "/DCTDecode"
|
||||||
|
|
|
@ -235,7 +235,7 @@ def _layerinfo(file):
|
||||||
if t:
|
if t:
|
||||||
tile.extend(t)
|
tile.extend(t)
|
||||||
layers[i] = name, mode, bbox, tile
|
layers[i] = name, mode, bbox, tile
|
||||||
i = i + 1
|
i += 1
|
||||||
|
|
||||||
return layers
|
return layers
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ def _maketile(file, mode, bbox, channels):
|
||||||
for channel in range(channels):
|
for channel in range(channels):
|
||||||
layer = mode[channel]
|
layer = mode[channel]
|
||||||
if mode == "CMYK":
|
if mode == "CMYK":
|
||||||
layer = layer + ";I"
|
layer += ";I"
|
||||||
tile.append(("raw", bbox, offset, layer))
|
tile.append(("raw", bbox, offset, layer))
|
||||||
offset = offset + xsize*ysize
|
offset = offset + xsize*ysize
|
||||||
|
|
||||||
|
@ -272,13 +272,13 @@ def _maketile(file, mode, bbox, channels):
|
||||||
for channel in range(channels):
|
for channel in range(channels):
|
||||||
layer = mode[channel]
|
layer = mode[channel]
|
||||||
if mode == "CMYK":
|
if mode == "CMYK":
|
||||||
layer = layer + ";I"
|
layer += ";I"
|
||||||
tile.append(
|
tile.append(
|
||||||
("packbits", bbox, offset, layer)
|
("packbits", bbox, offset, layer)
|
||||||
)
|
)
|
||||||
for y in range(ysize):
|
for y in range(ysize):
|
||||||
offset = offset + i16(bytecount[i:i+2])
|
offset = offset + i16(bytecount[i:i+2])
|
||||||
i = i + 2
|
i += 2
|
||||||
|
|
||||||
file.seek(offset)
|
file.seek(offset)
|
||||||
|
|
||||||
|
|
|
@ -558,9 +558,9 @@ class ImageFileDirectory(collections.MutableMapping):
|
||||||
count = count // 2 # adjust for rational data field
|
count = count // 2 # adjust for rational data field
|
||||||
|
|
||||||
append((tag, typ, count, o32(offset), data))
|
append((tag, typ, count, o32(offset), data))
|
||||||
offset = offset + len(data)
|
offset += len(data)
|
||||||
if offset & 1:
|
if offset & 1:
|
||||||
offset = offset + 1 # word padding
|
offset += 1 # word padding
|
||||||
|
|
||||||
# update strip offset data to point beyond auxiliary data
|
# update strip offset data to point beyond auxiliary data
|
||||||
if stripoffsets is not None:
|
if stripoffsets is not None:
|
||||||
|
@ -644,7 +644,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
self.fp.seek(self.__next)
|
self.fp.seek(self.__next)
|
||||||
self.tag.load(self.fp)
|
self.tag.load(self.fp)
|
||||||
self.__next = self.tag.next
|
self.__next = self.tag.next
|
||||||
self.__frame = self.__frame + 1
|
self.__frame += 1
|
||||||
self._setup()
|
self._setup()
|
||||||
|
|
||||||
def _tell(self):
|
def _tell(self):
|
||||||
|
@ -900,7 +900,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
y = y + h
|
y = y + h
|
||||||
if y >= self.size[1]:
|
if y >= self.size[1]:
|
||||||
x = y = 0
|
x = y = 0
|
||||||
l = l + 1
|
l += 1
|
||||||
a = None
|
a = None
|
||||||
elif TILEOFFSETS in self.tag:
|
elif TILEOFFSETS in self.tag:
|
||||||
# tiled image
|
# tiled image
|
||||||
|
@ -921,7 +921,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
||||||
x, y = 0, y + h
|
x, y = 0, y + h
|
||||||
if y >= self.size[1]:
|
if y >= self.size[1]:
|
||||||
x = y = 0
|
x = y = 0
|
||||||
l = l + 1
|
l += 1
|
||||||
a = None
|
a = None
|
||||||
else:
|
else:
|
||||||
if Image.DEBUG:
|
if Image.DEBUG:
|
||||||
|
|
|
@ -161,7 +161,7 @@ TAGS = {
|
||||||
50716: "BlackLevelDeltaV",
|
50716: "BlackLevelDeltaV",
|
||||||
50717: "WhiteLevel",
|
50717: "WhiteLevel",
|
||||||
50718: "DefaultScale",
|
50718: "DefaultScale",
|
||||||
50741: "BestQualityScale",
|
50741: "BestQualityScale", # FIXME! Dictionary contains duplicate keys 50741
|
||||||
50719: "DefaultCropOrigin",
|
50719: "DefaultCropOrigin",
|
||||||
50720: "DefaultCropSize",
|
50720: "DefaultCropSize",
|
||||||
50778: "CalibrationIlluminant1",
|
50778: "CalibrationIlluminant1",
|
||||||
|
@ -185,7 +185,7 @@ TAGS = {
|
||||||
50737: "ChromaBlurRadius",
|
50737: "ChromaBlurRadius",
|
||||||
50738: "AntiAliasStrength",
|
50738: "AntiAliasStrength",
|
||||||
50740: "DNGPrivateData",
|
50740: "DNGPrivateData",
|
||||||
50741: "MakerNoteSafety",
|
50741: "MakerNoteSafety", # FIXME! Dictionary contains duplicate keys 50741
|
||||||
|
|
||||||
#ImageJ
|
#ImageJ
|
||||||
50838: "ImageJMetaDataByteCounts", # private tag registered with Adobe
|
50838: "ImageJMetaDataByteCounts", # private tag registered with Adobe
|
||||||
|
|
|
@ -59,7 +59,7 @@ word = _binary.i16le
|
||||||
def short(c, o=0):
|
def short(c, o=0):
|
||||||
v = word(c, o)
|
v = word(c, o)
|
||||||
if v >= 32768:
|
if v >= 32768:
|
||||||
v = v - 65536
|
v -= 65536
|
||||||
return v
|
return v
|
||||||
|
|
||||||
dword = _binary.i32le
|
dword = _binary.i32le
|
||||||
|
|
|
@ -104,7 +104,7 @@ while True:
|
||||||
except EOFError:
|
except EOFError:
|
||||||
break
|
break
|
||||||
|
|
||||||
ix = ix + 1
|
ix += 1
|
||||||
|
|
||||||
if html:
|
if html:
|
||||||
html.write("</body>\n</html>\n")
|
html.write("</body>\n</html>\n")
|
||||||
|
|
|
@ -100,7 +100,7 @@ def makedelta(fp, sequence):
|
||||||
|
|
||||||
previous = im.copy()
|
previous = im.copy()
|
||||||
|
|
||||||
frames = frames + 1
|
frames += 1
|
||||||
|
|
||||||
fp.write(";")
|
fp.write(";")
|
||||||
|
|
||||||
|
|
|
@ -486,7 +486,7 @@ class PILDriver:
|
||||||
print("Stack: " + repr(self.stack))
|
print("Stack: " + repr(self.stack))
|
||||||
top = self.top()
|
top = self.top()
|
||||||
if not isinstance(top, str):
|
if not isinstance(top, str):
|
||||||
continue;
|
continue
|
||||||
funcname = "do_" + top
|
funcname = "do_" + top
|
||||||
if not hasattr(self, funcname):
|
if not hasattr(self, funcname):
|
||||||
continue
|
continue
|
||||||
|
@ -513,9 +513,9 @@ if __name__ == '__main__':
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
if sys.version_info[0] >= 3:
|
if sys.version_info[0] >= 3:
|
||||||
line = input('pildriver> ');
|
line = input('pildriver> ')
|
||||||
else:
|
else:
|
||||||
line = raw_input('pildriver> ');
|
line = raw_input('pildriver> ')
|
||||||
except EOFError:
|
except EOFError:
|
||||||
print("\nPILDriver says goodbye.")
|
print("\nPILDriver says goodbye.")
|
||||||
break
|
break
|
||||||
|
|
|
@ -57,7 +57,7 @@ for o, a in opt:
|
||||||
elif o == "-v":
|
elif o == "-v":
|
||||||
verify = 1
|
verify = 1
|
||||||
elif o == "-D":
|
elif o == "-D":
|
||||||
Image.DEBUG = Image.DEBUG + 1
|
Image.DEBUG += 1
|
||||||
|
|
||||||
def globfix(files):
|
def globfix(files):
|
||||||
# expand wildcards where necessary
|
# expand wildcards where necessary
|
||||||
|
|
BIN
Tests/images/rgb_trns_ycbc.j2k
Normal file
BIN
Tests/images/rgb_trns_ycbc.j2k
Normal file
Binary file not shown.
BIN
Tests/images/rgb_trns_ycbc.jp2
Normal file
BIN
Tests/images/rgb_trns_ycbc.jp2
Normal file
Binary file not shown.
|
@ -72,7 +72,7 @@ for file in files:
|
||||||
if not p.startswith('^'):
|
if not p.startswith('^'):
|
||||||
p = '^' + p
|
p = '^' + p
|
||||||
if not p.endswith('$'):
|
if not p.endswith('$'):
|
||||||
p = p + '$'
|
p += '$'
|
||||||
return p
|
return p
|
||||||
|
|
||||||
ignore_res = [re.compile(fix_re(p), re.MULTILINE) for p in ignore_pats]
|
ignore_res = [re.compile(fix_re(p), re.MULTILINE) for p in ignore_pats]
|
||||||
|
@ -104,7 +104,7 @@ for file in files:
|
||||||
print(result)
|
print(result)
|
||||||
failed.append(test)
|
failed.append(test)
|
||||||
else:
|
else:
|
||||||
success = success + 1
|
success += 1
|
||||||
|
|
||||||
print("-"*68)
|
print("-"*68)
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,18 @@ class TestFileJpeg2k(PillowTestCase):
|
||||||
im.load()
|
im.load()
|
||||||
self.assert_image_similar(im, test_card, 0.4)
|
self.assert_image_similar(im, test_card, 0.4)
|
||||||
|
|
||||||
|
def test_rgba(self):
|
||||||
|
# Arrange
|
||||||
|
j2k = Image.open('Tests/images/rgb_trns_ycbc.j2k')
|
||||||
|
jp2 = Image.open('Tests/images/rgb_trns_ycbc.jp2')
|
||||||
|
|
||||||
|
# Act
|
||||||
|
j2k.load()
|
||||||
|
jp2.load()
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
self.assertEqual(j2k.mode, 'RGBA')
|
||||||
|
self.assertEqual(jp2.mode, 'RGBA')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -110,7 +110,8 @@ class TestImageTransform(PillowTestCase):
|
||||||
# Running by default, but I'd totally understand not doing it in
|
# Running by default, but I'd totally understand not doing it in
|
||||||
# the future
|
# the future
|
||||||
|
|
||||||
foo = [Image.new('RGBA', (1024, 1024), (a, a, a, a))
|
foo = [
|
||||||
|
Image.new('RGBA', (1024, 1024), (a, a, a, a))
|
||||||
for a in range(1, 65)]
|
for a in range(1, 65)]
|
||||||
|
|
||||||
# Yeah. Watch some JIT optimize this out.
|
# Yeah. Watch some JIT optimize this out.
|
||||||
|
|
|
@ -18,7 +18,7 @@ class TestImageSequence(PillowTestCase):
|
||||||
for frame in seq:
|
for frame in seq:
|
||||||
self.assert_image_equal(im, frame)
|
self.assert_image_equal(im, frame)
|
||||||
self.assertEqual(im.tell(), index)
|
self.assertEqual(im.tell(), index)
|
||||||
index = index + 1
|
index += 1
|
||||||
|
|
||||||
self.assertEqual(index, 1)
|
self.assertEqual(index, 1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user