~ubuntu-branches/ubuntu/wily/python-imaging/wily

« back to all changes in this revision

Viewing changes to Tests/test_imageops.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-01-31 20:49:20 UTC
  • mfrom: (27.1.1 raring-proposed)
  • Revision ID: package-import@ubuntu.com-20130131204920-b5zshy6vgfvdionl
Tags: 1.1.7+1.7.8-1ubuntu1
Rewrite build dependencies to allow cross builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from tester import *
 
2
 
 
3
from PIL import Image
 
4
from PIL import ImageOps
 
5
 
 
6
class Deformer:
 
7
    def getmesh(self, im):
 
8
        x, y = im.size
 
9
        return [((0, 0, x, y), (0, 0, x, 0, x, y, y, 0))]
 
10
 
 
11
deformer = Deformer()
 
12
 
 
13
def test_sanity():
 
14
 
 
15
    ImageOps.autocontrast(lena("L"))
 
16
    ImageOps.autocontrast(lena("RGB"))
 
17
 
 
18
    ImageOps.autocontrast(lena("L"), cutoff=10)
 
19
    ImageOps.autocontrast(lena("L"), ignore=[0, 255])
 
20
 
 
21
    ImageOps.colorize(lena("L"), (0, 0, 0), (255, 255, 255))
 
22
    ImageOps.colorize(lena("L"), "black", "white")
 
23
 
 
24
    ImageOps.crop(lena("L"), 1)
 
25
    ImageOps.crop(lena("RGB"), 1)
 
26
 
 
27
    ImageOps.deform(lena("L"), deformer)
 
28
    ImageOps.deform(lena("RGB"), deformer)
 
29
 
 
30
    ImageOps.equalize(lena("L"))
 
31
    ImageOps.equalize(lena("RGB"))
 
32
 
 
33
    ImageOps.expand(lena("L"), 1)
 
34
    ImageOps.expand(lena("RGB"), 1)
 
35
    ImageOps.expand(lena("L"), 2, "blue")
 
36
    ImageOps.expand(lena("RGB"), 2, "blue")
 
37
 
 
38
    ImageOps.fit(lena("L"), (128, 128))
 
39
    ImageOps.fit(lena("RGB"), (128, 128))
 
40
 
 
41
    ImageOps.flip(lena("L"))
 
42
    ImageOps.flip(lena("RGB"))
 
43
 
 
44
    ImageOps.grayscale(lena("L"))
 
45
    ImageOps.grayscale(lena("RGB"))
 
46
 
 
47
    ImageOps.invert(lena("L"))
 
48
    ImageOps.invert(lena("RGB"))
 
49
 
 
50
    ImageOps.mirror(lena("L"))
 
51
    ImageOps.mirror(lena("RGB"))
 
52
 
 
53
    ImageOps.posterize(lena("L"), 4)
 
54
    ImageOps.posterize(lena("RGB"), 4)
 
55
 
 
56
    ImageOps.solarize(lena("L"))
 
57
    ImageOps.solarize(lena("RGB"))
 
58
 
 
59
    success()
 
60
 
 
61
def test_pil163():
 
62
    # Division by zero in equalize if < 255 pixels in image (@PIL163)
 
63
 
 
64
    i = lena("RGB").resize((15, 16))
 
65
 
 
66
    ImageOps.equalize(i.convert("L"))
 
67
    ImageOps.equalize(i.convert("P"))
 
68
    ImageOps.equalize(i.convert("RGB"))
 
69
 
 
70
    success()