-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from hugovk/master
Benchmarking script for Pillow
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/python | ||
|
||
import sys | ||
from PIL import Image, ImageFilter | ||
|
||
im = Image.open (sys.argv[1]) | ||
|
||
# Crop 100 pixels off all edges. | ||
im = im.crop ((100, 100, im.size[0] - 100, im.size[1] - 100)) | ||
|
||
# Shrink by 10% | ||
im = im.resize ((int (im.size[0] * 0.9), int (im.size[1] * 0.9)), | ||
Image.BILINEAR) | ||
|
||
# sharpen | ||
filter = ImageFilter.Kernel ((3, 3), | ||
(-1, -1, -1, | ||
-1, 16, -1, | ||
-1, -1, -1)) | ||
im = im.filter (filter) | ||
|
||
# write back again | ||
im.save (sys.argv[2]) | ||
|