mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
py3k: print is a function
Seriously, if you didn't know that, you've been in a freaking cave, man.
This commit is contained in:
parent
aeab3f5911
commit
5076c35cc5
|
@ -18,6 +18,8 @@
|
|||
# See the README file for information on usage and redistribution.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
__version__ = "0.4"
|
||||
|
||||
import Image, ImageFile, ImagePalette
|
||||
|
@ -70,8 +72,8 @@ class ArgStream(ChunkStream):
|
|||
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
|
||||
|
||||
|
@ -98,7 +100,7 @@ class ArgStream(ChunkStream):
|
|||
self.repair = None
|
||||
|
||||
if Image.DEBUG:
|
||||
print "AFRM", self.id, self.count
|
||||
print("AFRM", self.id, self.count)
|
||||
|
||||
return s
|
||||
|
||||
|
@ -121,7 +123,7 @@ class ArgStream(ChunkStream):
|
|||
self.count = i16(s[2:4])
|
||||
|
||||
if Image.DEBUG:
|
||||
print "ADEF", self.id, self.count
|
||||
print("ADEF", self.id, self.count)
|
||||
|
||||
return s
|
||||
|
||||
|
@ -141,7 +143,7 @@ class ArgStream(ChunkStream):
|
|||
"AEND -- end of animation"
|
||||
|
||||
if Image.DEBUG:
|
||||
print "AEND"
|
||||
print("AEND")
|
||||
|
||||
self.eof = 1
|
||||
|
||||
|
@ -256,7 +258,7 @@ class ArgStream(ChunkStream):
|
|||
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)
|
||||
|
@ -473,7 +475,7 @@ class ArgImageFile(ImageFile.ImageFile):
|
|||
|
||||
except "glurk": # AttributeError
|
||||
if Image.DEBUG:
|
||||
print cid, bytes, "(unknown)"
|
||||
print(cid, bytes, "(unknown)")
|
||||
s = self.fp.read(bytes)
|
||||
|
||||
self.arg.crc(cid, s)
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
# See the README file for information on usage and redistribution.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
VERSION = "1.1.7"
|
||||
|
||||
try:
|
||||
|
@ -355,8 +357,8 @@ def init():
|
|||
del sys.path[0]
|
||||
except ImportError:
|
||||
if DEBUG:
|
||||
print "Image: failed to import",
|
||||
print f, ":", sys.exc_info()[1]
|
||||
print("Image: failed to import", end=' ')
|
||||
print(f, ":", sys.exc_info()[1])
|
||||
visited[fullpath] = None
|
||||
|
||||
if OPEN or SAVE:
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
# below for the original description.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
DESCRIPTION = """
|
||||
pyCMS
|
||||
|
||||
|
@ -770,16 +772,16 @@ if __name__ == "__main__":
|
|||
# create a cheap manual from the __doc__ strings for the functions above
|
||||
|
||||
import ImageCms
|
||||
print __doc__
|
||||
print(__doc__)
|
||||
|
||||
for f in dir(pyCMS):
|
||||
print "="*80
|
||||
print "%s" %f
|
||||
print("="*80)
|
||||
print("%s" %f)
|
||||
|
||||
try:
|
||||
exec ("doc = ImageCms.%s.__doc__" %(f))
|
||||
if "pyCMS" in doc:
|
||||
# so we don't get the __doc__ string for imported modules
|
||||
print doc
|
||||
print(doc)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
# See the README file for information on usage and redistribution.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import Image
|
||||
import os, sys
|
||||
|
||||
|
@ -381,10 +383,10 @@ if __name__ == "__main__":
|
|||
# create font data chunk for embedding
|
||||
import base64, os, sys
|
||||
font = "../Images/courB08"
|
||||
print " f._load_pilfont_data("
|
||||
print " # %s" % os.path.basename(font)
|
||||
print " StringIO(base64.decodestring('''"
|
||||
print(" f._load_pilfont_data(")
|
||||
print(" # %s" % os.path.basename(font))
|
||||
print(" StringIO(base64.decodestring('''")
|
||||
base64.encode(open(font + ".pil", "rb"), sys.stdout)
|
||||
print "''')), Image.open(StringIO(base64.decodestring('''"
|
||||
print("''')), Image.open(StringIO(base64.decodestring('''")
|
||||
base64.encode(open(font + ".pbm", "rb"), sys.stdout)
|
||||
print "'''))))"
|
||||
print("'''))))")
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
# See the README file for information on usage and redistribution.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import Image
|
||||
import os, sys
|
||||
|
||||
|
@ -160,4 +162,4 @@ else:
|
|||
|
||||
if __name__ == "__main__":
|
||||
# usage: python ImageShow.py imagefile [title]
|
||||
print show(Image.open(sys.argv[1]), *sys.argv[2:])
|
||||
print(show(Image.open(sys.argv[1]), *sys.argv[2:]))
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
# See the README file for information on usage and redistribution.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
__version__ = "0.3"
|
||||
|
||||
|
@ -44,8 +45,8 @@ def i(c):
|
|||
|
||||
def dump(c):
|
||||
for i in c:
|
||||
print "%02x" % ord(i),
|
||||
print
|
||||
print("%02x" % ord(i), end=' ')
|
||||
print()
|
||||
|
||||
##
|
||||
# Image plugin for IPTC/NAA datastreams. To read IPTC/NAA fields
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
# See the README file for information on usage and redistribution.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import StringIO
|
||||
import sys
|
||||
|
||||
|
@ -208,12 +210,12 @@ class _OleDirectoryEntry:
|
|||
TYPES = ["(invalid)", "(storage)", "(stream)", "(lockbytes)",
|
||||
"(property)", "(root)"]
|
||||
|
||||
print " "*tab + repr(self.name), TYPES[self.type],
|
||||
print(" "*tab + repr(self.name), TYPES[self.type], end=' ')
|
||||
if self.type in (2, 5):
|
||||
print self.size, "bytes",
|
||||
print
|
||||
print(self.size, "bytes", end=' ')
|
||||
print()
|
||||
if self.type in (1, 5) and self.clsid:
|
||||
print " "*tab + "{%s}" % self.clsid
|
||||
print(" "*tab + "{%s}" % self.clsid)
|
||||
|
||||
for kid in self.kids:
|
||||
kid.dump(tab + 2)
|
||||
|
@ -515,17 +517,17 @@ if __name__ == "__main__":
|
|||
for file in sys.argv[1:]:
|
||||
try:
|
||||
ole = OleFileIO(file)
|
||||
print "-" * 68
|
||||
print file
|
||||
print "-" * 68
|
||||
print("-" * 68)
|
||||
print(file)
|
||||
print("-" * 68)
|
||||
ole.dumpdirectory()
|
||||
for file in ole.listdir():
|
||||
if file[-1][0] == "\005":
|
||||
print file
|
||||
print(file)
|
||||
props = ole.getproperties(file)
|
||||
props = list(props.items())
|
||||
props.sort()
|
||||
for k, v in props:
|
||||
print " ", k, v
|
||||
print(" ", k, v)
|
||||
except IOError as v:
|
||||
print "***", "cannot read", file, "-", v
|
||||
print("***", "cannot read", file, "-", v)
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
# See the README file for information on usage and redistribution.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import EpsImagePlugin
|
||||
|
||||
##
|
||||
|
@ -60,7 +62,7 @@ class PSDraw:
|
|||
self.fp.write("/F0 %d /PSDraw-%s F\n" % (size, font))
|
||||
|
||||
def setink(self, ink):
|
||||
print "*** NOT YET IMPLEMENTED ***"
|
||||
print("*** NOT YET IMPLEMENTED ***")
|
||||
|
||||
def line(self, xy0, xy1):
|
||||
xy = xy0 + xy1
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
# See the README file for information on usage and redistribution.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
__version__ = "0.9"
|
||||
|
||||
import re
|
||||
|
@ -111,7 +113,7 @@ class ChunkStream:
|
|||
"Call the appropriate chunk handler"
|
||||
|
||||
if Image.DEBUG:
|
||||
print "STREAM", cid, pos, len
|
||||
print("STREAM", cid, pos, len)
|
||||
return getattr(self, "chunk_" + cid)(pos, len)
|
||||
|
||||
def crc(self, cid, data):
|
||||
|
@ -191,8 +193,8 @@ class PngStream(ChunkStream):
|
|||
# Compressed profile n bytes (zlib with deflate compression)
|
||||
i = s.find(chr(0))
|
||||
if Image.DEBUG:
|
||||
print "iCCP profile name", s[:i]
|
||||
print "Compression method", ord(s[i])
|
||||
print("iCCP profile name", s[:i])
|
||||
print("Compression method", ord(s[i]))
|
||||
comp_method = ord(s[i])
|
||||
if comp_method != 0:
|
||||
raise SyntaxError("Unknown compression method %s in iCCP chunk" % comp_method)
|
||||
|
@ -333,7 +335,7 @@ class PngImageFile(ImageFile.ImageFile):
|
|||
break
|
||||
except AttributeError:
|
||||
if Image.DEBUG:
|
||||
print cid, pos, len, "(unknown)"
|
||||
print(cid, pos, len, "(unknown)")
|
||||
s = ImageFile._safe_read(self.fp, len)
|
||||
|
||||
self.png.crc(cid, s)
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
# http://www.wadsworth.org/spider_doc/spider/docs/image_doc.html
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import Image, ImageFile
|
||||
import os, struct, sys
|
||||
|
||||
|
@ -186,13 +188,13 @@ def loadImageSeries(filelist=None):
|
|||
imglist = []
|
||||
for img in filelist:
|
||||
if not os.path.exists(img):
|
||||
print "unable to find %s" % img
|
||||
print("unable to find %s" % img)
|
||||
continue
|
||||
try:
|
||||
im = Image.open(img).convert2byte()
|
||||
except:
|
||||
if not isSpiderImage(img):
|
||||
print img + " is not a Spider image file"
|
||||
print(img + " is not a Spider image file")
|
||||
continue
|
||||
im.info['filename'] = img
|
||||
imglist.append(im)
|
||||
|
@ -267,12 +269,12 @@ Image.register_save("SPIDER", _save_spider)
|
|||
if __name__ == "__main__":
|
||||
|
||||
if not sys.argv[1:]:
|
||||
print "Syntax: python SpiderImagePlugin.py Spiderimage [outfile]"
|
||||
print("Syntax: python SpiderImagePlugin.py Spiderimage [outfile]")
|
||||
sys.exit()
|
||||
|
||||
filename = sys.argv[1]
|
||||
if not isSpiderImage(filename):
|
||||
print "input image must be in Spider format"
|
||||
print("input image must be in Spider format")
|
||||
sys.exit()
|
||||
|
||||
outfile = ""
|
||||
|
@ -280,15 +282,15 @@ if __name__ == "__main__":
|
|||
outfile = sys.argv[2]
|
||||
|
||||
im = Image.open(filename)
|
||||
print "image: " + str(im)
|
||||
print "format: " + str(im.format)
|
||||
print "size: " + str(im.size)
|
||||
print "mode: " + str(im.mode)
|
||||
print "max, min: ",
|
||||
print im.getextrema()
|
||||
print("image: " + str(im))
|
||||
print("format: " + str(im.format))
|
||||
print("size: " + str(im.size))
|
||||
print("mode: " + str(im.mode))
|
||||
print("max, min: ", end=' ')
|
||||
print(im.getextrema())
|
||||
|
||||
if outfile != "":
|
||||
# perform some image operation
|
||||
im = im.transpose(Image.FLIP_LEFT_RIGHT)
|
||||
print "saving a flipped version of %s as %s " % (os.path.basename(filename), outfile)
|
||||
print("saving a flipped version of %s as %s " % (os.path.basename(filename), outfile))
|
||||
im.save(outfile, "SPIDER")
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
# See the README file for information on usage and redistribution.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
__version__ = "1.3.5"
|
||||
|
||||
import Image, ImageFile
|
||||
|
@ -352,14 +354,14 @@ class ImageFileDirectory(collections.MutableMapping):
|
|||
import TiffTags
|
||||
tagname = TiffTags.TAGS.get(tag, "unknown")
|
||||
typname = TiffTags.TYPES.get(typ, "unknown")
|
||||
print "tag: %s (%d)" % (tagname, tag),
|
||||
print "- type: %s (%d)" % (typname, typ),
|
||||
print("tag: %s (%d)" % (tagname, tag), end=' ')
|
||||
print("- type: %s (%d)" % (typname, typ), end=' ')
|
||||
|
||||
try:
|
||||
dispatch = self.load_dispatch[typ]
|
||||
except KeyError:
|
||||
if Image.DEBUG:
|
||||
print "- unsupported type", typ
|
||||
print("- unsupported type", typ)
|
||||
continue # ignore unsupported type
|
||||
|
||||
size, handler = dispatch
|
||||
|
@ -383,9 +385,9 @@ class ImageFileDirectory(collections.MutableMapping):
|
|||
|
||||
if Image.DEBUG:
|
||||
if tag in (COLORMAP, IPTC_NAA_CHUNK, PHOTOSHOP_CHUNK, ICCPROFILE, XMP):
|
||||
print "- value: <table: %d bytes>" % size
|
||||
print("- value: <table: %d bytes>" % size)
|
||||
else:
|
||||
print "- value:", self[tag]
|
||||
print("- value:", self[tag])
|
||||
|
||||
self.next = i32(fp.read(4))
|
||||
|
||||
|
@ -449,13 +451,13 @@ class ImageFileDirectory(collections.MutableMapping):
|
|||
import TiffTags
|
||||
tagname = TiffTags.TAGS.get(tag, "unknown")
|
||||
typname = TiffTags.TYPES.get(typ, "unknown")
|
||||
print "save: %s (%d)" % (tagname, tag),
|
||||
print "- type: %s (%d)" % (typname, typ),
|
||||
print("save: %s (%d)" % (tagname, tag), end=' ')
|
||||
print("- type: %s (%d)" % (typname, typ), end=' ')
|
||||
if tag in (COLORMAP, IPTC_NAA_CHUNK, PHOTOSHOP_CHUNK, ICCPROFILE, XMP):
|
||||
size = len(data)
|
||||
print "- value: <table: %d bytes>" % size
|
||||
print("- value: <table: %d bytes>" % size)
|
||||
else:
|
||||
print "- value:", value
|
||||
print("- value:", value)
|
||||
|
||||
# figure out if data fits into the directory
|
||||
if len(data) == 4:
|
||||
|
@ -481,7 +483,7 @@ class ImageFileDirectory(collections.MutableMapping):
|
|||
# pass 2: write directory to file
|
||||
for tag, typ, count, value, data in directory:
|
||||
if Image.DEBUG > 1:
|
||||
print tag, typ, count, repr(value), repr(data)
|
||||
print(tag, typ, count, repr(value), repr(data))
|
||||
fp.write(o16(tag) + o16(typ) + o32(count) + value)
|
||||
|
||||
# -- overwrite here for multi-page --
|
||||
|
@ -601,11 +603,11 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
fillorder = getscalar(FILLORDER, 1)
|
||||
|
||||
if Image.DEBUG:
|
||||
print "*** Summary ***"
|
||||
print "- compression:", self._compression
|
||||
print "- photometric_interpretation:", photo
|
||||
print "- planar_configuration:", self._planar_configuration
|
||||
print "- fill_order:", fillorder
|
||||
print("*** Summary ***")
|
||||
print("- compression:", self._compression)
|
||||
print("- photometric_interpretation:", photo)
|
||||
print("- planar_configuration:", self._planar_configuration)
|
||||
print("- fill_order:", fillorder)
|
||||
|
||||
# size
|
||||
xsize = getscalar(IMAGEWIDTH)
|
||||
|
@ -613,7 +615,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
self.size = xsize, ysize
|
||||
|
||||
if Image.DEBUG:
|
||||
print "- size:", self.size
|
||||
print("- size:", self.size)
|
||||
|
||||
format = getscalar(SAMPLEFORMAT, 1)
|
||||
|
||||
|
@ -624,17 +626,17 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
self.tag.get(EXTRASAMPLES, ())
|
||||
)
|
||||
if Image.DEBUG:
|
||||
print "format key:", key
|
||||
print("format key:", key)
|
||||
try:
|
||||
self.mode, rawmode = OPEN_INFO[key]
|
||||
except KeyError:
|
||||
if Image.DEBUG:
|
||||
print "- unsupported format"
|
||||
print("- unsupported format")
|
||||
raise SyntaxError("unknown pixel mode")
|
||||
|
||||
if Image.DEBUG:
|
||||
print "- raw mode:", rawmode
|
||||
print "- pil mode:", self.mode
|
||||
print("- raw mode:", rawmode)
|
||||
print("- pil mode:", self.mode)
|
||||
|
||||
self.info["compression"] = self._compression
|
||||
|
||||
|
@ -695,7 +697,7 @@ class TiffImageFile(ImageFile.ImageFile):
|
|||
a = None
|
||||
else:
|
||||
if Image.DEBUG:
|
||||
print "- unsupported data organization"
|
||||
print("- unsupported data organization")
|
||||
raise SyntaxError("unknown data organization")
|
||||
|
||||
# fixup palette descriptor
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
# http://www.flipcode.com/tutorials/tut_q2levels.shtml
|
||||
# and has been tested with a few sample files found using google.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import Image
|
||||
|
||||
def i32(c, o=0):
|
||||
|
@ -122,5 +124,5 @@ quake2palette = (
|
|||
|
||||
if __name__ == "__main__":
|
||||
im = open("../hacks/sample.wal")
|
||||
print im.info, im.mode, im.size
|
||||
print(im.info, im.mode, im.size)
|
||||
im.save("../out.png")
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
# Shows how to scan a 16 bit grayscale image into a numarray object
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# Get the path set up to find PIL modules if not installed yet:
|
||||
import sys ; sys.path.append('../PIL')
|
||||
|
||||
|
@ -23,8 +25,8 @@ def toImage(arr):
|
|||
im = Image.fromstring('L', arr.shape[::-1], arr.tostring())
|
||||
return im
|
||||
|
||||
print 'SANE version:', sane.init()
|
||||
print 'Available devices=', sane.get_devices()
|
||||
print('SANE version:', sane.init())
|
||||
print('Available devices=', sane.get_devices())
|
||||
|
||||
s = sane.open(sane.get_devices()[0][0])
|
||||
|
||||
|
@ -32,7 +34,7 @@ s = sane.open(sane.get_devices()[0][0])
|
|||
s.mode = 'gray'
|
||||
s.br_x=320. ; s.br_y=240.
|
||||
|
||||
print 'Device parameters:', s.get_parameters()
|
||||
print('Device parameters:', s.get_parameters())
|
||||
|
||||
s.depth=16
|
||||
arr16 = s.arr_scan()
|
||||
|
|
|
@ -4,19 +4,21 @@
|
|||
# Shows how to scan a color image into a PIL rgb-image
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
# Get the path set up to find PIL modules if not installed yet:
|
||||
import sys ; sys.path.append('../PIL')
|
||||
|
||||
import sane
|
||||
print 'SANE version:', sane.init()
|
||||
print 'Available devices=', sane.get_devices()
|
||||
print('SANE version:', sane.init())
|
||||
print('Available devices=', sane.get_devices())
|
||||
|
||||
s = sane.open(sane.get_devices()[0][0])
|
||||
|
||||
s.mode = 'color'
|
||||
s.br_x=320. ; s.br_y=240.
|
||||
|
||||
print 'Device parameters:', s.get_parameters()
|
||||
print('Device parameters:', s.get_parameters())
|
||||
|
||||
# Initiate the scan
|
||||
s.start()
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
# split an animation into a number of frame files
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from PIL import Image
|
||||
import os, sys
|
||||
|
||||
|
@ -53,17 +55,17 @@ if sys.argv[1:2] == ["-h"]:
|
|||
del sys.argv[1]
|
||||
|
||||
if not sys.argv[2:]:
|
||||
print
|
||||
print "Syntax: python explode.py infile template [range]"
|
||||
print
|
||||
print "The template argument is used to construct the names of the"
|
||||
print "individual frame files. The frames are numbered file001.ext,"
|
||||
print "file002.ext, etc. You can insert %d to control the placement"
|
||||
print "and syntax of the frame number."
|
||||
print
|
||||
print "The optional range argument specifies which frames to extract."
|
||||
print "You can give one or more ranges like 1-10, 5, -15 etc. If"
|
||||
print "omitted, all frames are extracted."
|
||||
print()
|
||||
print("Syntax: python explode.py infile template [range]")
|
||||
print()
|
||||
print("The template argument is used to construct the names of the")
|
||||
print("individual frame files. The frames are numbered file001.ext,")
|
||||
print("file002.ext, etc. You can insert %d to control the placement")
|
||||
print("and syntax of the frame number.")
|
||||
print()
|
||||
print("The optional range argument specifies which frames to extract.")
|
||||
print("You can give one or more ranges like 1-10, 5, -15 etc. If")
|
||||
print("omitted, all frames are extracted.")
|
||||
sys.exit(1)
|
||||
|
||||
infile = sys.argv[1]
|
||||
|
@ -91,7 +93,7 @@ while 1:
|
|||
|
||||
if frames[ix]:
|
||||
im.save(outfile % ix)
|
||||
print outfile % ix
|
||||
print(outfile % ix)
|
||||
|
||||
if html:
|
||||
html.write("<img src='%s'><br>\n" % outfile % ix)
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
# write data directly to a socket. Or something...
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from PIL import Image, ImageChops
|
||||
|
||||
from PIL.GifImagePlugin import getheader, getdata
|
||||
|
@ -127,8 +129,8 @@ if __name__ == "__main__":
|
|||
import sys
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
print "GIFMAKER -- create GIF animations"
|
||||
print "Usage: gifmaker infile outfile"
|
||||
print("GIFMAKER -- create GIF animations")
|
||||
print("Usage: gifmaker infile outfile")
|
||||
sys.exit(1)
|
||||
|
||||
compress(sys.argv[1], sys.argv[2])
|
||||
|
|
|
@ -13,27 +13,29 @@
|
|||
# 0.5 98-12-30 fl Fixed -f option (from Anthony Baxter)
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import site
|
||||
import getopt, string, sys
|
||||
|
||||
from PIL import Image
|
||||
|
||||
def usage():
|
||||
print "PIL Convert 0.5/1998-12-30 -- convert image files"
|
||||
print "Usage: pilconvert [option] infile outfile"
|
||||
print
|
||||
print "Options:"
|
||||
print
|
||||
print " -c <format> convert to format (default is given by extension)"
|
||||
print
|
||||
print " -g convert to greyscale"
|
||||
print " -p convert to palette image (using standard palette)"
|
||||
print " -r convert to rgb"
|
||||
print
|
||||
print " -o optimize output (trade speed for size)"
|
||||
print " -q <value> set compression quality (0-100, JPEG only)"
|
||||
print
|
||||
print " -f list supported file formats"
|
||||
print("PIL Convert 0.5/1998-12-30 -- convert image files")
|
||||
print("Usage: pilconvert [option] infile outfile")
|
||||
print()
|
||||
print("Options:")
|
||||
print()
|
||||
print(" -c <format> convert to format (default is given by extension)")
|
||||
print()
|
||||
print(" -g convert to greyscale")
|
||||
print(" -p convert to palette image (using standard palette)")
|
||||
print(" -r convert to rgb")
|
||||
print()
|
||||
print(" -o optimize output (trade speed for size)")
|
||||
print(" -q <value> set compression quality (0-100, JPEG only)")
|
||||
print()
|
||||
print(" -f list supported file formats")
|
||||
sys.exit(1)
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
|
@ -42,7 +44,7 @@ if len(sys.argv) == 1:
|
|||
try:
|
||||
opt, argv = getopt.getopt(sys.argv[1:], "c:dfgopq:r")
|
||||
except getopt.error as v:
|
||||
print v
|
||||
print(v)
|
||||
sys.exit(1)
|
||||
|
||||
format = None
|
||||
|
@ -56,12 +58,12 @@ for o, a in opt:
|
|||
Image.init()
|
||||
id = Image.ID[:]
|
||||
id.sort()
|
||||
print "Supported formats (* indicates output format):"
|
||||
print("Supported formats (* indicates output format):")
|
||||
for i in id:
|
||||
if i in Image.SAVE:
|
||||
print i+"*",
|
||||
print(i+"*", end=' ')
|
||||
else:
|
||||
print i,
|
||||
print(i, end=' ')
|
||||
sys.exit(1)
|
||||
|
||||
elif o == "-c":
|
||||
|
@ -92,5 +94,5 @@ try:
|
|||
else:
|
||||
apply(im.save, (argv[1],), options)
|
||||
except:
|
||||
print "cannot convert image",
|
||||
print "(%s:%s)" % (sys.exc_info()[0], sys.exc_info()[1])
|
||||
print("cannot convert image", end=' ')
|
||||
print("(%s:%s)" % (sys.exc_info()[0], sys.exc_info()[1]))
|
||||
|
|
|
@ -48,6 +48,8 @@ of its upper-left-hand corner and displays the cropped portion.
|
|||
# 3. Add support for composing and decomposing multiple-image files.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from PIL import Image
|
||||
|
||||
class PILDriver:
|
||||
|
@ -481,7 +483,7 @@ class PILDriver:
|
|||
self.push(list[0])
|
||||
list = list[1:]
|
||||
if self.verbose:
|
||||
print "Stack: " + `self.stack`
|
||||
print("Stack: " + `self.stack`)
|
||||
top = self.top()
|
||||
if type(top) != type(""):
|
||||
continue;
|
||||
|
@ -507,15 +509,15 @@ if __name__ == '__main__':
|
|||
if len(sys.argv[1:]) > 0:
|
||||
driver.execute(sys.argv[1:])
|
||||
else:
|
||||
print "PILDriver says hello."
|
||||
print("PILDriver says hello.")
|
||||
while 1:
|
||||
try:
|
||||
line = raw_input('pildriver> ');
|
||||
except EOFError:
|
||||
print "\nPILDriver says goodbye."
|
||||
print("\nPILDriver says goodbye.")
|
||||
break
|
||||
driver.execute(line.split())
|
||||
print driver.stack
|
||||
print(driver.stack)
|
||||
|
||||
# The following sets edit modes for GNU EMACS
|
||||
# Local Variables:
|
||||
|
|
|
@ -17,25 +17,27 @@
|
|||
# 0.4 2003-09-30 fl Expand wildcards on Windows; robustness tweaks
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import site
|
||||
import getopt, glob, sys
|
||||
|
||||
from PIL import Image
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print "PIL File 0.4/2003-09-30 -- identify image files"
|
||||
print "Usage: pilfile [option] files..."
|
||||
print "Options:"
|
||||
print " -f list supported file formats"
|
||||
print " -i show associated info and tile data"
|
||||
print " -v verify file headers"
|
||||
print " -q quiet, don't warn for unidentified/missing/broken files"
|
||||
print("PIL File 0.4/2003-09-30 -- identify image files")
|
||||
print("Usage: pilfile [option] files...")
|
||||
print("Options:")
|
||||
print(" -f list supported file formats")
|
||||
print(" -i show associated info and tile data")
|
||||
print(" -v verify file headers")
|
||||
print(" -q quiet, don't warn for unidentified/missing/broken files")
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
opt, args = getopt.getopt(sys.argv[1:], "fqivD")
|
||||
except getopt.error as v:
|
||||
print v
|
||||
print(v)
|
||||
sys.exit(1)
|
||||
|
||||
verbose = quiet = verify = 0
|
||||
|
@ -45,9 +47,9 @@ for o, a in opt:
|
|||
Image.init()
|
||||
id = Image.ID[:]
|
||||
id.sort()
|
||||
print "Supported formats:"
|
||||
print("Supported formats:")
|
||||
for i in id:
|
||||
print i,
|
||||
print(i, end=' ')
|
||||
sys.exit(1)
|
||||
elif o == "-i":
|
||||
verbose = 1
|
||||
|
@ -73,22 +75,22 @@ def globfix(files):
|
|||
for file in globfix(args):
|
||||
try:
|
||||
im = Image.open(file)
|
||||
print "%s:" % file, im.format, "%dx%d" % im.size, im.mode,
|
||||
print("%s:" % file, im.format, "%dx%d" % im.size, im.mode, end=' ')
|
||||
if verbose:
|
||||
print im.info, im.tile,
|
||||
print
|
||||
print(im.info, im.tile, end=' ')
|
||||
print()
|
||||
if verify:
|
||||
try:
|
||||
im.verify()
|
||||
except:
|
||||
if not quiet:
|
||||
print "failed to verify image",
|
||||
print "(%s:%s)" % (sys.exc_info()[0], sys.exc_info()[1])
|
||||
print("failed to verify image", end=' ')
|
||||
print("(%s:%s)" % (sys.exc_info()[0], sys.exc_info()[1]))
|
||||
except IOError as v:
|
||||
if not quiet:
|
||||
print file, "failed:", v
|
||||
print(file, "failed:", v)
|
||||
except:
|
||||
import traceback
|
||||
if not quiet:
|
||||
print file, "failed:", "unexpected error"
|
||||
print(file, "failed:", "unexpected error")
|
||||
traceback.print_exc(file=sys.stdout)
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
# 2002-03-10 fl use "from PIL import"
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
VERSION = "0.4"
|
||||
|
||||
import site
|
||||
|
@ -19,12 +21,12 @@ from PIL import BdfFontFile
|
|||
from PIL import PcfFontFile
|
||||
|
||||
if len(sys.argv) <= 1:
|
||||
print "PILFONT", VERSION, "-- PIL font compiler."
|
||||
print
|
||||
print "Usage: pilfont fontfiles..."
|
||||
print
|
||||
print "Convert given font files to the PIL raster font format."
|
||||
print "This version of pilfont supports X BDF and PCF fonts."
|
||||
print("PILFONT", VERSION, "-- PIL font compiler.")
|
||||
print()
|
||||
print("Usage: pilfont fontfiles...")
|
||||
print()
|
||||
print("Convert given font files to the PIL raster font format.")
|
||||
print("This version of pilfont supports X BDF and PCF fonts.")
|
||||
sys.exit(1)
|
||||
|
||||
files = []
|
||||
|
@ -33,7 +35,7 @@ for f in sys.argv[1:]:
|
|||
|
||||
for f in files:
|
||||
|
||||
print f + "...",
|
||||
print(f + "...", end=' ')
|
||||
|
||||
try:
|
||||
|
||||
|
@ -48,7 +50,7 @@ for f in files:
|
|||
p.save(f)
|
||||
|
||||
except (SyntaxError, IOError):
|
||||
print "failed"
|
||||
print("failed")
|
||||
|
||||
else:
|
||||
print "OK"
|
||||
print("OK")
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
# 0.3 2003-05-06 fl Fixed a typo or two.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
VERSION = "pilprint 0.3/2003-05-05"
|
||||
|
||||
from PIL import Image
|
||||
|
@ -29,18 +31,18 @@ def description(file, image):
|
|||
import getopt, os, sys
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print "PIL Print 0.2a1/96-10-04 -- print image files"
|
||||
print "Usage: pilprint files..."
|
||||
print "Options:"
|
||||
print " -c colour printer (default is monochrome)"
|
||||
print " -p print via lpr (default is stdout)"
|
||||
print " -P <printer> same as -p but use given printer"
|
||||
print("PIL Print 0.2a1/96-10-04 -- print image files")
|
||||
print("Usage: pilprint files...")
|
||||
print("Options:")
|
||||
print(" -c colour printer (default is monochrome)")
|
||||
print(" -p print via lpr (default is stdout)")
|
||||
print(" -P <printer> same as -p but use given printer")
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
opt, argv = getopt.getopt(sys.argv[1:], "cdpP:")
|
||||
except getopt.error as v:
|
||||
print v
|
||||
print(v)
|
||||
sys.exit(1)
|
||||
|
||||
printer = None # print to stdout
|
||||
|
@ -50,7 +52,7 @@ for o, a in opt:
|
|||
if o == "-d":
|
||||
# debug: show available drivers
|
||||
Image.init()
|
||||
print Image.ID
|
||||
print(Image.ID)
|
||||
sys.exit(1)
|
||||
elif o == "-c":
|
||||
# colour printer
|
||||
|
@ -89,5 +91,5 @@ for file in argv:
|
|||
ps.end_document()
|
||||
|
||||
except:
|
||||
print "cannot print image",
|
||||
print "(%s:%s)" % (sys.exc_info()[0], sys.exc_info()[1])
|
||||
print("cannot print image", end=' ')
|
||||
print("(%s:%s)" % (sys.exc_info()[0], sys.exc_info()[1]))
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
# $Id$
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from Tkinter import *
|
||||
from PIL import Image, ImageTk
|
||||
import sys
|
||||
|
@ -98,7 +100,7 @@ class UI(Label):
|
|||
if __name__ == "__main__":
|
||||
|
||||
if not sys.argv[1:]:
|
||||
print "Syntax: python player.py imagefile(s)"
|
||||
print("Syntax: python player.py imagefile(s)")
|
||||
sys.exit(1)
|
||||
|
||||
filename = sys.argv[1]
|
||||
|
@ -108,7 +110,7 @@ if __name__ == "__main__":
|
|||
|
||||
if len(sys.argv) > 2:
|
||||
# list of images
|
||||
print "loading..."
|
||||
print("loading...")
|
||||
im = []
|
||||
for filename in sys.argv[1:]:
|
||||
im.append(Image.open(filename))
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
# $Id$
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from Tkinter import *
|
||||
from PIL import Image, ImageTk
|
||||
|
||||
|
@ -31,7 +33,7 @@ if __name__ == "__main__":
|
|||
import sys
|
||||
|
||||
if not sys.argv[1:]:
|
||||
print "Syntax: python viewer.py imagefile"
|
||||
print("Syntax: python viewer.py imagefile")
|
||||
sys.exit(1)
|
||||
|
||||
filename = sys.argv[1]
|
||||
|
|
Loading…
Reference in New Issue
Block a user