mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Fix pildriver script
This commit is contained in:
parent
e09ff61b81
commit
03b8960db2
|
@ -61,7 +61,7 @@ class PILDriver:
|
||||||
|
|
||||||
Set verbosity flag from top of stack.
|
Set verbosity flag from top of stack.
|
||||||
"""
|
"""
|
||||||
self.verbose = self.do_pop()
|
self.verbose = int(self.do_pop())
|
||||||
|
|
||||||
# The evaluation stack (internal only)
|
# The evaluation stack (internal only)
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ class PILDriver:
|
||||||
|
|
||||||
Process the top image with the given filter.
|
Process the top image with the given filter.
|
||||||
"""
|
"""
|
||||||
import ImageFilter
|
from PIL import ImageFilter
|
||||||
filter = eval("ImageFilter." + self.do_pop().upper())
|
filter = eval("ImageFilter." + self.do_pop().upper())
|
||||||
image = self.do_pop()
|
image = self.do_pop()
|
||||||
self.push(image.filter(filter))
|
self.push(image.filter(filter))
|
||||||
|
@ -326,21 +326,21 @@ class PILDriver:
|
||||||
|
|
||||||
Push the format of the top image onto the stack.
|
Push the format of the top image onto the stack.
|
||||||
"""
|
"""
|
||||||
self.push(self.pop().format)
|
self.push(self.do_pop().format)
|
||||||
|
|
||||||
def do_mode(self):
|
def do_mode(self):
|
||||||
"""usage: mode <image:pic1>
|
"""usage: mode <image:pic1>
|
||||||
|
|
||||||
Push the mode of the top image onto the stack.
|
Push the mode of the top image onto the stack.
|
||||||
"""
|
"""
|
||||||
self.push(self.pop().mode)
|
self.push(self.do_pop().mode)
|
||||||
|
|
||||||
def do_size(self):
|
def do_size(self):
|
||||||
"""usage: size <image:pic1>
|
"""usage: size <image:pic1>
|
||||||
|
|
||||||
Push the image size on the stack as (y, x).
|
Push the image size on the stack as (y, x).
|
||||||
"""
|
"""
|
||||||
size = self.pop().size
|
size = self.do_pop().size
|
||||||
self.push(size[0])
|
self.push(size[0])
|
||||||
self.push(size[1])
|
self.push(size[1])
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ class PILDriver:
|
||||||
|
|
||||||
Invert the top image.
|
Invert the top image.
|
||||||
"""
|
"""
|
||||||
import ImageChops
|
from PIL import ImageChops
|
||||||
self.push(ImageChops.invert(self.do_pop()))
|
self.push(ImageChops.invert(self.do_pop()))
|
||||||
|
|
||||||
def do_lighter(self):
|
def do_lighter(self):
|
||||||
|
@ -359,7 +359,7 @@ class PILDriver:
|
||||||
|
|
||||||
Pop the two top images, push an image of the lighter pixels of both.
|
Pop the two top images, push an image of the lighter pixels of both.
|
||||||
"""
|
"""
|
||||||
import ImageChops
|
from PIL import ImageChops
|
||||||
image1 = self.do_pop()
|
image1 = self.do_pop()
|
||||||
image2 = self.do_pop()
|
image2 = self.do_pop()
|
||||||
self.push(ImageChops.lighter(image1, image2))
|
self.push(ImageChops.lighter(image1, image2))
|
||||||
|
@ -369,7 +369,7 @@ class PILDriver:
|
||||||
|
|
||||||
Pop the two top images, push an image of the darker pixels of both.
|
Pop the two top images, push an image of the darker pixels of both.
|
||||||
"""
|
"""
|
||||||
import ImageChops
|
from PIL import ImageChops
|
||||||
image1 = self.do_pop()
|
image1 = self.do_pop()
|
||||||
image2 = self.do_pop()
|
image2 = self.do_pop()
|
||||||
self.push(ImageChops.darker(image1, image2))
|
self.push(ImageChops.darker(image1, image2))
|
||||||
|
@ -379,7 +379,7 @@ class PILDriver:
|
||||||
|
|
||||||
Pop the two top images, push the difference image
|
Pop the two top images, push the difference image
|
||||||
"""
|
"""
|
||||||
import ImageChops
|
from PIL import ImageChops
|
||||||
image1 = self.do_pop()
|
image1 = self.do_pop()
|
||||||
image2 = self.do_pop()
|
image2 = self.do_pop()
|
||||||
self.push(ImageChops.difference(image1, image2))
|
self.push(ImageChops.difference(image1, image2))
|
||||||
|
@ -389,7 +389,7 @@ class PILDriver:
|
||||||
|
|
||||||
Pop the two top images, push the multiplication image.
|
Pop the two top images, push the multiplication image.
|
||||||
"""
|
"""
|
||||||
import ImageChops
|
from PIL import ImageChops
|
||||||
image1 = self.do_pop()
|
image1 = self.do_pop()
|
||||||
image2 = self.do_pop()
|
image2 = self.do_pop()
|
||||||
self.push(ImageChops.multiply(image1, image2))
|
self.push(ImageChops.multiply(image1, image2))
|
||||||
|
@ -399,7 +399,7 @@ class PILDriver:
|
||||||
|
|
||||||
Pop the two top images, superimpose their inverted versions.
|
Pop the two top images, superimpose their inverted versions.
|
||||||
"""
|
"""
|
||||||
import ImageChops
|
from PIL import ImageChops
|
||||||
image2 = self.do_pop()
|
image2 = self.do_pop()
|
||||||
image1 = self.do_pop()
|
image1 = self.do_pop()
|
||||||
self.push(ImageChops.screen(image1, image2))
|
self.push(ImageChops.screen(image1, image2))
|
||||||
|
@ -409,7 +409,7 @@ class PILDriver:
|
||||||
|
|
||||||
Pop the two top images, produce the scaled sum with offset.
|
Pop the two top images, produce the scaled sum with offset.
|
||||||
"""
|
"""
|
||||||
import ImageChops
|
from PIL import ImageChops
|
||||||
image1 = self.do_pop()
|
image1 = self.do_pop()
|
||||||
image2 = self.do_pop()
|
image2 = self.do_pop()
|
||||||
scale = float(self.do_pop())
|
scale = float(self.do_pop())
|
||||||
|
@ -421,7 +421,7 @@ class PILDriver:
|
||||||
|
|
||||||
Pop the two top images, produce the scaled difference with offset.
|
Pop the two top images, produce the scaled difference with offset.
|
||||||
"""
|
"""
|
||||||
import ImageChops
|
from PIL import ImageChops
|
||||||
image1 = self.do_pop()
|
image1 = self.do_pop()
|
||||||
image2 = self.do_pop()
|
image2 = self.do_pop()
|
||||||
scale = float(self.do_pop())
|
scale = float(self.do_pop())
|
||||||
|
@ -435,7 +435,7 @@ class PILDriver:
|
||||||
|
|
||||||
Enhance color in the top image.
|
Enhance color in the top image.
|
||||||
"""
|
"""
|
||||||
import ImageEnhance
|
from PIL import ImageEnhance
|
||||||
factor = float(self.do_pop())
|
factor = float(self.do_pop())
|
||||||
image = self.do_pop()
|
image = self.do_pop()
|
||||||
enhancer = ImageEnhance.Color(image)
|
enhancer = ImageEnhance.Color(image)
|
||||||
|
@ -446,10 +446,10 @@ class PILDriver:
|
||||||
|
|
||||||
Enhance contrast in the top image.
|
Enhance contrast in the top image.
|
||||||
"""
|
"""
|
||||||
import ImageEnhance
|
from PIL import ImageEnhance
|
||||||
factor = float(self.do_pop())
|
factor = float(self.do_pop())
|
||||||
image = self.do_pop()
|
image = self.do_pop()
|
||||||
enhancer = ImageEnhance.Color(image)
|
enhancer = ImageEnhance.Contrast(image)
|
||||||
self.push(enhancer.enhance(factor))
|
self.push(enhancer.enhance(factor))
|
||||||
|
|
||||||
def do_brightness(self):
|
def do_brightness(self):
|
||||||
|
@ -457,10 +457,10 @@ class PILDriver:
|
||||||
|
|
||||||
Enhance brightness in the top image.
|
Enhance brightness in the top image.
|
||||||
"""
|
"""
|
||||||
import ImageEnhance
|
from PIL import ImageEnhance
|
||||||
factor = float(self.do_pop())
|
factor = float(self.do_pop())
|
||||||
image = self.do_pop()
|
image = self.do_pop()
|
||||||
enhancer = ImageEnhance.Color(image)
|
enhancer = ImageEnhance.Brightness(image)
|
||||||
self.push(enhancer.enhance(factor))
|
self.push(enhancer.enhance(factor))
|
||||||
|
|
||||||
def do_sharpness(self):
|
def do_sharpness(self):
|
||||||
|
@ -468,10 +468,10 @@ class PILDriver:
|
||||||
|
|
||||||
Enhance sharpness in the top image.
|
Enhance sharpness in the top image.
|
||||||
"""
|
"""
|
||||||
import ImageEnhance
|
from PIL import ImageEnhance
|
||||||
factor = float(self.do_pop())
|
factor = float(self.do_pop())
|
||||||
image = self.do_pop()
|
image = self.do_pop()
|
||||||
enhancer = ImageEnhance.Color(image)
|
enhancer = ImageEnhance.Sharpness(image)
|
||||||
self.push(enhancer.enhance(factor))
|
self.push(enhancer.enhance(factor))
|
||||||
|
|
||||||
# The interpreter loop
|
# The interpreter loop
|
||||||
|
@ -512,7 +512,10 @@ if __name__ == '__main__':
|
||||||
print("PILDriver says hello.")
|
print("PILDriver says hello.")
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
line = raw_input('pildriver> ');
|
if sys.version_info[0] >= 3:
|
||||||
|
line = input('pildriver> ');
|
||||||
|
else:
|
||||||
|
line = raw_input('pildriver> ');
|
||||||
except EOFError:
|
except EOFError:
|
||||||
print("\nPILDriver says goodbye.")
|
print("\nPILDriver says goodbye.")
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue
Block a user