Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
37f22eb
py3k: Use string methods instead of string module
Oct 10, 2012
7857579
py3k: Update exception usage to modern syntax
Oct 11, 2012
009eee0
py3k: Get setup.py to run under python3
Oct 11, 2012
9519013
py3k: Modernize type declarations
Oct 13, 2012
804095e
py3k: Use new buffer protocol
Oct 20, 2012
d28a2fe
py3k: Remove HAVE_UNICODE from _imagingft
Oct 13, 2012
89e82c5
py3k: Fix strict aliasing slip-up in _imaging
Oct 14, 2012
af52288
py3k: Add module initialization and unicode/bytes int/long thunks
Oct 14, 2012
4459715
py3k: Fix strict aliasing warnings under Python 3
Oct 14, 2012
9631d42
py3k: Use "y#" code in PyArg_ParseTuple where we expect byte data
Oct 14, 2012
ad784eb
py3k: Import Christoph Gohlke's test suite
Oct 15, 2012
1978851
py3k: Backport Gohlke's tests to run on 2.6/2.7
Oct 15, 2012
c8ce29c
FIX: Handle long values in _imaging getink
Oct 15, 2012
718dbcc
py3k: Provide the missing pngtest_bad.png.base64
Oct 15, 2012
b386ed1
py3k: Remove callable() function
Oct 15, 2012
09f1081
py3k: Fix up uses of dictionary views, ranges, and has_key()
Oct 15, 2012
e514912
py3k: Rewrite dictionary support for Tiff ImageFileDictionary
Oct 15, 2012
fc03581
py3k: map and filter to list comprehensions
Oct 16, 2012
3a665a7
py3k: Add true Unicode support to OleFileIO
Oct 16, 2012
eed042f
py3k: __nonzero__ is now __bool__
Oct 16, 2012
da1d715
py3k: Use isinstance for numbers and sequences
Oct 16, 2012
aeab3f5
py3k: Import reduce function
Oct 16, 2012
5076c35
py3k: print is a function
Oct 16, 2012
abd215e
py3k: Remove tuples in parameter lists
Oct 16, 2012
83ff0b3
py3k: Use relative imports
Oct 16, 2012
a453007
py3k: sys.maxint renamed to sys.maxsize
Oct 16, 2012
f6fa094
py3k: Convert backticks to repr()
Oct 16, 2012
dfb1b14
py3k: Remove Image types import
Oct 16, 2012
fa348ee
py3k: __builtin__ module is now builtins
Oct 17, 2012
dda0e9a
py3k: Tkinter module is now tkinter
Oct 17, 2012
260c1fa
py3k: Convert StringIO.StringIO to io.BytesIO
Oct 17, 2012
e2283c6
py3k: Integer long literals are no longer valid syntax
Oct 17, 2012
48cf699
py3k: Change apply() to unpacking syntax
Oct 20, 2012
31c454b
py3k: 2to3's "idiom" filter
Oct 17, 2012
af94e2d
py3k: Map long type to int
Oct 17, 2012
80c2fa6
py3k: Sort by key, not cmp
Oct 17, 2012
275a895
py3k: Type coercion is gone
Oct 19, 2012
8b704e3
py3k: Publish both frombytes and fromstring in C modules for old Python
Oct 20, 2012
a7e3b2e
py3k: The big push
Oct 20, 2012
be560f0
py3k: Allow slicing for paths
cgohlke Oct 21, 2012
a8599e8
py3k: Remove ancient Python hacks
Oct 21, 2012
254f0cf
py3k: FIX: Bad upside-down check in BmpImagePlugin
Oct 24, 2012
8035b1a
py3k: FIX: TGA missing o8 declaration
Oct 24, 2012
63be4a1
py3k: Get rid of _ParserFile; io.BytesIO does its job
Oct 24, 2012
4f7d784
py3k: Actually fix the EPS encoder
Oct 24, 2012
2972b21
py3k: Add PCX to roundtrip test
Oct 24, 2012
9921d83
py3k: Add Photoshop sanity check
Oct 24, 2012
6765b8e
py3k: Add .FLI sanity check, and fix palette bytes bug
Oct 24, 2012
49b0d15
py3k: Rewrite PdfImagePlugin into something more legible
Oct 24, 2012
d6a0dec
py3k: Add TarIO test
Oct 25, 2012
276cc42
py3k: Add XPM read test
Oct 25, 2012
848579a
py3k: Add Windows icon sanity test
Oct 25, 2012
ec961de
py3k: Remove use_2to3 from setup.py
Oct 28, 2012
a1c1654
py3k: inquiry is now lenfunc
Oct 30, 2012
c952134
py3k: Issue warnings when using the old fromstring/tostring
Nov 9, 2012
decabcf
Fix tox test running: port selftest.py to Python 3; make it clear Pyt…
kmike Oct 29, 2012
67a131a
Update the manifest to include a lot of missing files
Nov 10, 2012
e84cc92
Make pysane Python3-compatible
manisandro Dec 23, 2012
fb2ccb1
Set up Sane error object as exception instead of string
Jan 10, 2013
e49cba9
Handle Sane option strings as Unicode strings
Jan 10, 2013
9f82f02
Modified map.c to fix some MSVC10 compilation errors.
Jan 10, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Images/lena.fli
Binary file not shown.
Binary file added Images/lena.ico
Binary file not shown.
Binary file added Images/lena.psd
Binary file not shown.
Binary file added Images/lena.tar
Binary file not shown.
175 changes: 175 additions & 0 deletions Images/lena.xpm

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ include *.rst
include *.c
include *.h
include selftest.py tox.ini
recursive-include Tests *.py *.txt
graft Tests/fonts
graft Tests/icc
graft Tests/images
recursive-include Scripts *.py README
graft Images
recursive-include docs *.txt *.html *.rst *.css *.py README CHANGES CONTENTS Makefile make.bat
Expand Down
82 changes: 42 additions & 40 deletions PIL/ArgImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
# See the README file for information on usage and redistribution.
#

from __future__ import print_function

__version__ = "0.4"

import Image, ImageFile, ImagePalette
from . import Image, ImageFile, ImagePalette

from PngImagePlugin import i16, i32, ChunkStream, _MODES
from .PngImagePlugin import i8, i16, i32, ChunkStream, _MODES

MAGIC = "\212ARG\r\n\032\n"
MAGIC = b"\212ARG\r\n\032\n"

# --------------------------------------------------------------------
# ARG parser
Expand Down Expand Up @@ -60,18 +62,18 @@ def chunk_AHDR(self, offset, bytes):

# assertions
if self.count != 0:
raise SyntaxError, "misplaced AHDR chunk"
raise SyntaxError("misplaced AHDR chunk")

s = self.fp.read(bytes)
self.size = i32(s), i32(s[4:])
try:
self.mode, self.rawmode = _MODES[(ord(s[8]), ord(s[9]))]
self.mode, self.rawmode = _MODES[(i8(s[8]), i8(s[9]))]
except:
raise SyntaxError, "unknown ARG mode"
raise SyntaxError("unknown ARG mode")

if Image.DEBUG:
print "AHDR size", self.size
print "AHDR mode", self.mode, self.rawmode
print("AHDR size", self.size)
print("AHDR mode", self.mode, self.rawmode)

return s

Expand All @@ -80,7 +82,7 @@ def chunk_AFRM(self, offset, bytes):

# assertions
if self.count != 0:
raise SyntaxError, "misplaced AFRM chunk"
raise SyntaxError("misplaced AFRM chunk")

self.show = 1
self.id = 0
Expand All @@ -98,7 +100,7 @@ def chunk_AFRM(self, offset, bytes):
self.repair = None

if Image.DEBUG:
print "AFRM", self.id, self.count
print("AFRM", self.id, self.count)

return s

Expand All @@ -107,7 +109,7 @@ def chunk_ADEF(self, offset, bytes):

# assertions
if self.count != 0:
raise SyntaxError, "misplaced ADEF chunk"
raise SyntaxError("misplaced ADEF chunk")

self.show = 0
self.id = 0
Expand All @@ -121,7 +123,7 @@ def chunk_ADEF(self, offset, bytes):
self.count = i16(s[2:4])

if Image.DEBUG:
print "ADEF", self.id, self.count
print("ADEF", self.id, self.count)

return s

Expand All @@ -130,7 +132,7 @@ def chunk_NAME(self, offset, bytes):

# assertions
if self.count == 0:
raise SyntaxError, "misplaced NAME chunk"
raise SyntaxError("misplaced NAME chunk")

name = self.fp.read(bytes)
self.names[self.id] = name
Expand All @@ -141,26 +143,26 @@ def chunk_AEND(self, offset, bytes):
"AEND -- end of animation"

if Image.DEBUG:
print "AEND"
print("AEND")

self.eof = 1

raise EOFError, "end of ARG file"
raise EOFError("end of ARG file")

def __getmodesize(self, s, full=1):

size = i32(s), i32(s[4:])

try:
mode, rawmode = _MODES[(ord(s[8]), ord(s[9]))]
mode, rawmode = _MODES[(i8(s[8]), i8(s[9]))]
except:
raise SyntaxError, "unknown image mode"
raise SyntaxError("unknown image mode")

if full:
if ord(s[12]):
if i8(s[12]):
pass # interlace not yet supported
if ord(s[11]):
raise SyntaxError, "unknown filter category"
if i8(s[11]):
raise SyntaxError("unknown filter category")

return size, mode, rawmode

Expand All @@ -169,7 +171,7 @@ def chunk_PAST(self, offset, bytes):

# assertions
if self.count == 0:
raise SyntaxError, "misplaced PAST chunk"
raise SyntaxError("misplaced PAST chunk")

if self.repair is not None:
# we must repair the target image before we
Expand Down Expand Up @@ -206,7 +208,7 @@ def chunk_BLNK(self, offset, bytes):

# assertions
if self.count == 0:
raise SyntaxError, "misplaced BLNK chunk"
raise SyntaxError("misplaced BLNK chunk")

s = self.fp.read(bytes)
size, mode, rawmode = self.__getmodesize(s, 0)
Expand All @@ -223,7 +225,7 @@ def chunk_IHDR(self, offset, bytes):

# assertions
if self.count == 0:
raise SyntaxError, "misplaced IHDR chunk"
raise SyntaxError("misplaced IHDR chunk")

# image header
s = self.fp.read(bytes)
Expand All @@ -234,7 +236,7 @@ def chunk_IHDR(self, offset, bytes):
self.im = Image.core.new(mode, size)
self.decoder = Image.core.zip_decoder(rawmode)
self.decoder.setimage(self.im, (0,0) + size)
self.data = ""
self.data = b""

return s

Expand All @@ -243,20 +245,20 @@ def chunk_DHDR(self, offset, bytes):

# assertions
if self.count == 0:
raise SyntaxError, "misplaced DHDR chunk"
raise SyntaxError("misplaced DHDR chunk")

s = self.fp.read(bytes)

size, mode, rawmode = self.__getmodesize(s)

# delta header
diff = ord(s[13])
diff = i8(s[13])
offs = i32(s[14:18]), i32(s[18:22])

bbox = offs + (offs[0]+size[0], offs[1]+size[1])

if Image.DEBUG:
print "DHDR", diff, bbox
print("DHDR", diff, bbox)

# FIXME: decode and apply image
self.action = ("DHDR", diff, bbox)
Expand All @@ -267,7 +269,7 @@ def chunk_DHDR(self, offset, bytes):
self.decoder = Image.core.zip_decoder(rawmode)
self.decoder.setimage(self.im, (0,0) + size)

self.data = ""
self.data = b""

return s

Expand All @@ -276,7 +278,7 @@ def chunk_JHDR(self, offset, bytes):

# assertions
if self.count == 0:
raise SyntaxError, "misplaced JHDR chunk"
raise SyntaxError("misplaced JHDR chunk")

# image header
s = self.fp.read(bytes)
Expand All @@ -287,7 +289,7 @@ def chunk_JHDR(self, offset, bytes):
self.im = Image.core.new(mode, size)
self.decoder = Image.core.jpeg_decoder(rawmode)
self.decoder.setimage(self.im, (0,0) + size)
self.data = ""
self.data = b""

return s

Expand All @@ -296,7 +298,7 @@ def chunk_UHDR(self, offset, bytes):

# assertions
if self.count == 0:
raise SyntaxError, "misplaced UHDR chunk"
raise SyntaxError("misplaced UHDR chunk")

# image header
s = self.fp.read(bytes)
Expand All @@ -307,7 +309,7 @@ def chunk_UHDR(self, offset, bytes):
self.im = Image.core.new(mode, size)
self.decoder = Image.core.raw_decoder(rawmode)
self.decoder.setimage(self.im, (0,0) + size)
self.data = ""
self.data = b""

return s

Expand All @@ -321,7 +323,7 @@ def chunk_IDAT(self, offset, bytes):
if n < 0:
# end of image
if e < 0:
raise IOError, "decoder error %d" % e
raise IOError("decoder error %d" % e)
else:
self.data = self.data[n:]

Expand Down Expand Up @@ -386,7 +388,7 @@ def chunk_sYNC(self, offset, bytes):
"SYNC -- reset decoder"

if self.count != 0:
raise SyntaxError, "misplaced sYNC chunk"
raise SyntaxError("misplaced sYNC chunk")

s = self.fp.read(bytes)
self.__reset()
Expand Down Expand Up @@ -418,7 +420,7 @@ def _open(self):
)

if self.fp.read(8) != MAGIC:
raise SyntaxError, "not an ARG file"
raise SyntaxError("not an ARG file")

self.arg = ArgStream(self.fp)

Expand All @@ -427,7 +429,7 @@ def _open(self):
cid, offset, bytes = self.arg.read()

if cid != "AHDR":
raise SyntaxError, "expected an AHDR chunk"
raise SyntaxError("expected an AHDR chunk")

s = self.arg.call(cid, offset, bytes)

Expand All @@ -452,19 +454,19 @@ def load(self):
def seek(self, frame):

if self.arg.eof:
raise EOFError, "end of animation"
raise EOFError("end of animation")

self.fp = self.arg.fp

while 1:
while True:

#
# process chunks

cid, offset, bytes = self.arg.read()

if self.arg.eof:
raise EOFError, "end of animation"
raise EOFError("end of animation")

try:
s = self.arg.call(cid, offset, bytes)
Expand All @@ -473,7 +475,7 @@ def seek(self, frame):

except "glurk": # AttributeError
if Image.DEBUG:
print cid, bytes, "(unknown)"
print(cid, bytes, "(unknown)")
s = self.fp.read(bytes)

self.arg.crc(cid, s)
Expand Down
Loading