Skip to content

Commit

Permalink
Removed black background from rotated images.
Browse files Browse the repository at this point in the history
  • Loading branch information
philsc committed May 19, 2013
1 parent 5ca781c commit f8fc621
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions testcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from scantron import ScantronGenerator, ScantronField, inch
import PythonMagick
from pyPdf import PdfFileReader
from PIL import Image
from PIL import Image, ImageOps

test_data = [
ScantronField('foo', 'Foo foo foo', int),
Expand Down Expand Up @@ -35,9 +35,16 @@
pages.append(name)

# Create a series of transformations to apply
def rotate(im, deg):
blank = Image.new('L', im.size, 255)
mask = blank.rotate(deg, expand=False)
mask = ImageOps.invert(mask)
rot = im.rotate(deg, expand=False)
return Image.composite(blank, rot, mask)

transformations = [
lambda x: x.rotate(10, expand=False),
lambda x: x.rotate(-10, expand=False),
lambda x: rotate(x, 10),
lambda x: rotate(x, -10),
]

tf = 0
Expand Down

0 comments on commit f8fc621

Please sign in to comment.