@@ -61,7 +61,7 @@ def do_verbose(self):
61
61
62
62
Set verbosity flag from top of stack.
63
63
"""
64
- self .verbose = self .do_pop ()
64
+ self .verbose = int ( self .do_pop () )
65
65
66
66
# The evaluation stack (internal only)
67
67
@@ -206,7 +206,7 @@ def do_filter(self):
206
206
207
207
Process the top image with the given filter.
208
208
"""
209
- import ImageFilter
209
+ from PIL import ImageFilter
210
210
filter = eval ("ImageFilter." + self .do_pop ().upper ())
211
211
image = self .do_pop ()
212
212
self .push (image .filter (filter ))
@@ -326,21 +326,21 @@ def do_format(self):
326
326
327
327
Push the format of the top image onto the stack.
328
328
"""
329
- self .push (self .pop ().format )
329
+ self .push (self .do_pop ().format )
330
330
331
331
def do_mode (self ):
332
332
"""usage: mode <image:pic1>
333
333
334
334
Push the mode of the top image onto the stack.
335
335
"""
336
- self .push (self .pop ().mode )
336
+ self .push (self .do_pop ().mode )
337
337
338
338
def do_size (self ):
339
339
"""usage: size <image:pic1>
340
340
341
341
Push the image size on the stack as (y, x).
342
342
"""
343
- size = self .pop ().size
343
+ size = self .do_pop ().size
344
344
self .push (size [0 ])
345
345
self .push (size [1 ])
346
346
@@ -351,15 +351,15 @@ def do_invert(self):
351
351
352
352
Invert the top image.
353
353
"""
354
- import ImageChops
354
+ from PIL import ImageChops
355
355
self .push (ImageChops .invert (self .do_pop ()))
356
356
357
357
def do_lighter (self ):
358
358
"""usage: lighter <image:pic1> <image:pic2>
359
359
360
360
Pop the two top images, push an image of the lighter pixels of both.
361
361
"""
362
- import ImageChops
362
+ from PIL import ImageChops
363
363
image1 = self .do_pop ()
364
364
image2 = self .do_pop ()
365
365
self .push (ImageChops .lighter (image1 , image2 ))
@@ -369,7 +369,7 @@ def do_darker(self):
369
369
370
370
Pop the two top images, push an image of the darker pixels of both.
371
371
"""
372
- import ImageChops
372
+ from PIL import ImageChops
373
373
image1 = self .do_pop ()
374
374
image2 = self .do_pop ()
375
375
self .push (ImageChops .darker (image1 , image2 ))
@@ -379,7 +379,7 @@ def do_difference(self):
379
379
380
380
Pop the two top images, push the difference image
381
381
"""
382
- import ImageChops
382
+ from PIL import ImageChops
383
383
image1 = self .do_pop ()
384
384
image2 = self .do_pop ()
385
385
self .push (ImageChops .difference (image1 , image2 ))
@@ -389,7 +389,7 @@ def do_multiply(self):
389
389
390
390
Pop the two top images, push the multiplication image.
391
391
"""
392
- import ImageChops
392
+ from PIL import ImageChops
393
393
image1 = self .do_pop ()
394
394
image2 = self .do_pop ()
395
395
self .push (ImageChops .multiply (image1 , image2 ))
@@ -399,7 +399,7 @@ def do_screen(self):
399
399
400
400
Pop the two top images, superimpose their inverted versions.
401
401
"""
402
- import ImageChops
402
+ from PIL import ImageChops
403
403
image2 = self .do_pop ()
404
404
image1 = self .do_pop ()
405
405
self .push (ImageChops .screen (image1 , image2 ))
@@ -409,7 +409,7 @@ def do_add(self):
409
409
410
410
Pop the two top images, produce the scaled sum with offset.
411
411
"""
412
- import ImageChops
412
+ from PIL import ImageChops
413
413
image1 = self .do_pop ()
414
414
image2 = self .do_pop ()
415
415
scale = float (self .do_pop ())
@@ -421,7 +421,7 @@ def do_subtract(self):
421
421
422
422
Pop the two top images, produce the scaled difference with offset.
423
423
"""
424
- import ImageChops
424
+ from PIL import ImageChops
425
425
image1 = self .do_pop ()
426
426
image2 = self .do_pop ()
427
427
scale = float (self .do_pop ())
@@ -435,7 +435,7 @@ def do_color(self):
435
435
436
436
Enhance color in the top image.
437
437
"""
438
- import ImageEnhance
438
+ from PIL import ImageEnhance
439
439
factor = float (self .do_pop ())
440
440
image = self .do_pop ()
441
441
enhancer = ImageEnhance .Color (image )
@@ -446,32 +446,32 @@ def do_contrast(self):
446
446
447
447
Enhance contrast in the top image.
448
448
"""
449
- import ImageEnhance
449
+ from PIL import ImageEnhance
450
450
factor = float (self .do_pop ())
451
451
image = self .do_pop ()
452
- enhancer = ImageEnhance .Color (image )
452
+ enhancer = ImageEnhance .Contrast (image )
453
453
self .push (enhancer .enhance (factor ))
454
454
455
455
def do_brightness (self ):
456
456
"""usage: brightness <image:pic1>
457
457
458
458
Enhance brightness in the top image.
459
459
"""
460
- import ImageEnhance
460
+ from PIL import ImageEnhance
461
461
factor = float (self .do_pop ())
462
462
image = self .do_pop ()
463
- enhancer = ImageEnhance .Color (image )
463
+ enhancer = ImageEnhance .Brightness (image )
464
464
self .push (enhancer .enhance (factor ))
465
465
466
466
def do_sharpness (self ):
467
467
"""usage: sharpness <image:pic1>
468
468
469
469
Enhance sharpness in the top image.
470
470
"""
471
- import ImageEnhance
471
+ from PIL import ImageEnhance
472
472
factor = float (self .do_pop ())
473
473
image = self .do_pop ()
474
- enhancer = ImageEnhance .Color (image )
474
+ enhancer = ImageEnhance .Sharpness (image )
475
475
self .push (enhancer .enhance (factor ))
476
476
477
477
# The interpreter loop
@@ -512,7 +512,10 @@ def execute(self, list):
512
512
print ("PILDriver says hello." )
513
513
while True :
514
514
try :
515
- line = raw_input ('pildriver> ' );
515
+ if sys .version_info [0 ] >= 3 :
516
+ line = input ('pildriver> ' );
517
+ else :
518
+ line = raw_input ('pildriver> ' );
516
519
except EOFError :
517
520
print ("\n PILDriver says goodbye." )
518
521
break
0 commit comments