mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-05-03 23:43:40 +03:00
Various Flake8 Scripts fixes
This commit is contained in:
parent
d1c182cadc
commit
86be744d1f
|
@ -18,6 +18,7 @@ import sys
|
||||||
#
|
#
|
||||||
# enhancer widget
|
# enhancer widget
|
||||||
|
|
||||||
|
|
||||||
class Enhance(Frame):
|
class Enhance(Frame):
|
||||||
def __init__(self, master, image, name, enhancer, lo, hi):
|
def __init__(self, master, image, name, enhancer, lo, hi):
|
||||||
Frame.__init__(self, master)
|
Frame.__init__(self, master)
|
||||||
|
@ -25,7 +26,7 @@ class Enhance(Frame):
|
||||||
# set up the image
|
# set up the image
|
||||||
self.tkim = ImageTk.PhotoImage(image.mode, image.size)
|
self.tkim = ImageTk.PhotoImage(image.mode, image.size)
|
||||||
self.enhancer = enhancer(image)
|
self.enhancer = enhancer(image)
|
||||||
self.update("1.0") # normalize
|
self.update("1.0") # normalize
|
||||||
|
|
||||||
# image window
|
# image window
|
||||||
Label(self, image=self.tkim).pack()
|
Label(self, image=self.tkim).pack()
|
||||||
|
|
|
@ -9,11 +9,13 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
import os, sys
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
class Interval:
|
class Interval:
|
||||||
|
|
||||||
def __init__(self, interval = "0"):
|
def __init__(self, interval="0"):
|
||||||
|
|
||||||
self.setinterval(interval)
|
self.setinterval(interval)
|
||||||
|
|
||||||
|
|
|
@ -49,20 +49,23 @@ from PIL.GifImagePlugin import getheader, getdata
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# sequence iterator
|
# sequence iterator
|
||||||
|
|
||||||
|
|
||||||
class image_sequence:
|
class image_sequence:
|
||||||
def __init__(self, im):
|
def __init__(self, im):
|
||||||
self.im = im
|
self.im = im
|
||||||
|
|
||||||
def __getitem__(self, ix):
|
def __getitem__(self, ix):
|
||||||
try:
|
try:
|
||||||
if ix:
|
if ix:
|
||||||
self.im.seek(ix)
|
self.im.seek(ix)
|
||||||
return self.im
|
return self.im
|
||||||
except EOFError:
|
except EOFError:
|
||||||
raise IndexError # end of sequence
|
raise IndexError # end of sequence
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# straightforward delta encoding
|
# straightforward delta encoding
|
||||||
|
|
||||||
|
|
||||||
def makedelta(fp, sequence):
|
def makedelta(fp, sequence):
|
||||||
"""Convert list of image frames to a GIF animation file"""
|
"""Convert list of image frames to a GIF animation file"""
|
||||||
|
|
||||||
|
@ -91,7 +94,7 @@ def makedelta(fp, sequence):
|
||||||
if bbox:
|
if bbox:
|
||||||
|
|
||||||
# compress difference
|
# compress difference
|
||||||
for s in getdata(im.crop(bbox), offset = bbox[:2]):
|
for s in getdata(im.crop(bbox), offset=bbox[:2]):
|
||||||
fp.write(s)
|
fp.write(s)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -109,6 +112,7 @@ def makedelta(fp, sequence):
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# main hack
|
# main hack
|
||||||
|
|
||||||
|
|
||||||
def compress(infile, outfile):
|
def compress(infile, outfile):
|
||||||
|
|
||||||
# open input image, and force loading of first frame
|
# open input image, and force loading of first frame
|
||||||
|
|
|
@ -20,6 +20,7 @@ import sys
|
||||||
#
|
#
|
||||||
# painter widget
|
# painter widget
|
||||||
|
|
||||||
|
|
||||||
class PaintCanvas(Canvas):
|
class PaintCanvas(Canvas):
|
||||||
def __init__(self, master, image):
|
def __init__(self, master, image):
|
||||||
Canvas.__init__(self, master, width=image.size[0], height=image.size[1])
|
Canvas.__init__(self, master, width=image.size[0], height=image.size[1])
|
||||||
|
@ -33,7 +34,7 @@ class PaintCanvas(Canvas):
|
||||||
box = x, y, min(xsize, x+tilesize), min(ysize, y+tilesize)
|
box = x, y, min(xsize, x+tilesize), min(ysize, y+tilesize)
|
||||||
tile = ImageTk.PhotoImage(image.crop(box))
|
tile = ImageTk.PhotoImage(image.crop(box))
|
||||||
self.create_image(x, y, image=tile, anchor=NW)
|
self.create_image(x, y, image=tile, anchor=NW)
|
||||||
self.tile[(x,y)] = box, tile
|
self.tile[(x, y)] = box, tile
|
||||||
|
|
||||||
self.image = image
|
self.image = image
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ class PaintCanvas(Canvas):
|
||||||
xy, tile = self.tile[(x, y)]
|
xy, tile = self.tile[(x, y)]
|
||||||
tile.paste(self.image.crop(xy))
|
tile.paste(self.image.crop(xy))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass # outside the image
|
pass # outside the image
|
||||||
self.update_idletasks()
|
self.update_idletasks()
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -15,10 +15,13 @@
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import getopt, string, sys
|
import getopt
|
||||||
|
import string
|
||||||
|
import sys
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print("PIL Convert 0.5/1998-12-30 -- convert image files")
|
print("PIL Convert 0.5/1998-12-30 -- convert image files")
|
||||||
print("Usage: pilconvert [option] infile outfile")
|
print("Usage: pilconvert [option] infile outfile")
|
||||||
|
@ -49,7 +52,7 @@ except getopt.error as v:
|
||||||
format = None
|
format = None
|
||||||
convert = None
|
convert = None
|
||||||
|
|
||||||
options = { }
|
options = {}
|
||||||
|
|
||||||
for o, a in opt:
|
for o, a in opt:
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ from __future__ import print_function
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
class PILDriver:
|
class PILDriver:
|
||||||
|
|
||||||
verbose = 0
|
verbose = 0
|
||||||
|
@ -500,7 +501,7 @@ if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
import readline
|
import readline
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pass # not available on all platforms
|
pass # not available on all platforms
|
||||||
|
|
||||||
# If we see command-line arguments, interpret them as a stack state
|
# If we see command-line arguments, interpret them as a stack state
|
||||||
# and execute. Otherwise go interactive.
|
# and execute. Otherwise go interactive.
|
||||||
|
|
|
@ -20,7 +20,9 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import site
|
import site
|
||||||
import getopt, glob, sys
|
import getopt
|
||||||
|
import glob
|
||||||
|
import sys
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
@ -59,6 +61,7 @@ for o, a in opt:
|
||||||
elif o == "-D":
|
elif o == "-D":
|
||||||
Image.DEBUG += 1
|
Image.DEBUG += 1
|
||||||
|
|
||||||
|
|
||||||
def globfix(files):
|
def globfix(files):
|
||||||
# expand wildcards where necessary
|
# expand wildcards where necessary
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
|
|
|
@ -14,7 +14,8 @@ from __future__ import print_function
|
||||||
|
|
||||||
VERSION = "0.4"
|
VERSION = "0.4"
|
||||||
|
|
||||||
import glob, sys
|
import glob
|
||||||
|
import sys
|
||||||
|
|
||||||
# drivers
|
# drivers
|
||||||
from PIL import BdfFontFile
|
from PIL import BdfFontFile
|
||||||
|
|
|
@ -12,14 +12,17 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import getopt, os, sys
|
import getopt
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
VERSION = "pilprint 0.3/2003-05-05"
|
VERSION = "pilprint 0.3/2003-05-05"
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from PIL import PSDraw
|
from PIL import PSDraw
|
||||||
|
|
||||||
letter = ( 1.0*72, 1.0*72, 7.5*72, 10.0*72 )
|
letter = (1.0*72, 1.0*72, 7.5*72, 10.0*72)
|
||||||
|
|
||||||
|
|
||||||
def description(file, image):
|
def description(file, image):
|
||||||
title = os.path.splitext(os.path.split(file)[1])[0]
|
title = os.path.splitext(os.path.split(file)[1])[0]
|
||||||
|
@ -43,8 +46,8 @@ except getopt.error as v:
|
||||||
print(v)
|
print(v)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
printer = None # print to stdout
|
printer = None # print to stdout
|
||||||
monochrome = 1 # reduce file size for most common case
|
monochrome = 1 # reduce file size for most common case
|
||||||
|
|
||||||
for o, a in opt:
|
for o, a in opt:
|
||||||
if o == "-d":
|
if o == "-d":
|
||||||
|
|
|
@ -56,7 +56,7 @@ class UI(Label):
|
||||||
del self.im[0]
|
del self.im[0]
|
||||||
self.image.paste(im)
|
self.image.paste(im)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return # end of list
|
return # end of list
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ class UI(Label):
|
||||||
im.seek(im.tell() + 1)
|
im.seek(im.tell() + 1)
|
||||||
self.image.paste(im)
|
self.image.paste(im)
|
||||||
except EOFError:
|
except EOFError:
|
||||||
return # end of file
|
return # end of file
|
||||||
|
|
||||||
try:
|
try:
|
||||||
duration = im.info["duration"]
|
duration = im.info["duration"]
|
||||||
|
|
|
@ -18,8 +18,9 @@ import sys
|
||||||
#
|
#
|
||||||
# an image viewer
|
# an image viewer
|
||||||
|
|
||||||
|
|
||||||
class UI(Frame):
|
class UI(Frame):
|
||||||
def __init__(self, master, im, value = 128):
|
def __init__(self, master, im, value=128):
|
||||||
Frame.__init__(self, master)
|
Frame.__init__(self, master)
|
||||||
|
|
||||||
self.image = im
|
self.image = im
|
||||||
|
@ -45,16 +46,16 @@ class UI(Frame):
|
||||||
|
|
||||||
self.redraw()
|
self.redraw()
|
||||||
|
|
||||||
def redraw(self, event = None):
|
def redraw(self, event=None):
|
||||||
|
|
||||||
# create overlay (note the explicit conversion to mode "1")
|
# create overlay (note the explicit conversion to mode "1")
|
||||||
im = self.image.point(lambda v,t=self.value: v>=t, "1")
|
im = self.image.point(lambda v, t=self.value: v >= t, "1")
|
||||||
self.overlay = ImageTk.BitmapImage(im, foreground="green")
|
self.overlay = ImageTk.BitmapImage(im, foreground="green")
|
||||||
|
|
||||||
# update canvas
|
# update canvas
|
||||||
self.canvas.delete("overlay")
|
self.canvas.delete("overlay")
|
||||||
self.canvas.create_image(0, 0, image=self.overlay, anchor=NW,
|
self.canvas.create_image(0, 0, image=self.overlay, anchor=NW,
|
||||||
tags="overlay")
|
tags="overlay")
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# main
|
# main
|
||||||
|
|
|
@ -16,6 +16,7 @@ from PIL import Image, ImageTk
|
||||||
#
|
#
|
||||||
# an image viewer
|
# an image viewer
|
||||||
|
|
||||||
|
|
||||||
class UI(Label):
|
class UI(Label):
|
||||||
|
|
||||||
def __init__(self, master, im):
|
def __init__(self, master, im):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user