Skip to content

Commit

Permalink
update pillow
Browse files Browse the repository at this point in the history
see #3
  • Loading branch information
jcupitt committed Feb 12, 2015
1 parent cd05a2d commit 2b82e53
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
15 changes: 8 additions & 7 deletions benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ benchmark vips-c "./vips-c $tmp/x.ppm $tmp/x2.ppm"
gcc -Wall vips.c `pkg-config vips --cflags --libs` -o vips-c
benchmark vips-c "./vips-c $tmp/x.tif $tmp/x2.tif"

g++ vips8.cc `pkg-config vips-cpp --cflags --libs` -o vips8-cc
benchmark vips8-cc "./vips8-cc $tmp/x.tif $tmp/x2.tif"

g++ vips.cc `pkg-config vipsCC --cflags --libs` -o vips-cc
benchmark vips-cc "./vips-cc $tmp/x.tif $tmp/x2.tif"

benchmark vips.py "./vips.py $tmp/x.tif $tmp/x2.tif"

g++ vips8.cc `pkg-config vips-cpp --cflags --libs` -o vips8-cc
benchmark vips8-cc "./vips8-cc $tmp/x.tif $tmp/x2.tif"

benchmark vips8.py "./vips8.py $tmp/x.tif $tmp/x2.tif"

benchmark ruby-vips "./ruby-vips.rb $tmp/x.tif $tmp/x2.tif"
Expand All @@ -118,11 +118,11 @@ benchmark opencv "./opencv $tmp/x.tif $tmp/x2.tif"
echo -n ppm-
benchmark gm "./gm.sh $tmp/x.ppm $tmp/x2.ppm"

benchmark gm "./gm.sh $tmp/x.tif $tmp/x2.tif"

echo -n jpg-
benchmark gm "./gm.sh $tmp/x.jpg $tmp/x2.jpg"

benchmark gm "./gm.sh $tmp/x.tif $tmp/x2.tif"

benchmark pnm "./netpbm.sh $tmp/x_strip.tif $tmp/x2.tif"

benchmark convert "./im.sh $tmp/x.tif $tmp/x2.tif"
Expand All @@ -131,13 +131,14 @@ benchmark econvert "./ei.sh $tmp/x_strip.tif $tmp/x2.tif"

benchmark rmagick "./rmagick.rb $tmp/x.tif $tmp/x2.tif"

# benchmark pil "./pil.py $tmp/x.tif $tmp/x2.tif"
benchmark pillow "./pillow.py $tmp/x.tif $tmp/x2.tif"

benchmark gmic "./gmic.sh $tmp/x.tif $tmp/x2.tif"

gcc freeimage.c -lfreeimage -o freeimage
benchmark freeimage "./freeimage $tmp/x.tif $tmp/x2.tif"

benchmark pil "./pil.py $tmp/x.tif $tmp/x2.tif"

gcc -Wall gd.c `pkg-config gdlib --cflags --libs` -o gd
benchmark gd "./gd $tmp/x.jpg $tmp/x2.jpg"

Expand Down
24 changes: 16 additions & 8 deletions pillow.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
#!/usr/bin/python

import sys
from PIL import Image, ImageFilter
from PIL import Image, ImageFilter, PILLOW_VERSION

im = Image.open (sys.argv[1])
# just to confirm we are getting the right version
# print("pillow.py: PILLOW_VERSION =", PILLOW_VERSION)

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))
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)

# starting with 2.7, Pillow uses a high-quality convolution-based resize for
# BILINEAR ... the other systems in this benchmark are using affine + bilinear,
# so this is rather unfair. Use NEAREST instead, it gets closest to what
# everyone else is doing

im = im.resize((int (im.size[0] * 0.9), int (im.size[1] * 0.9)), Image.NEAREST)

# sharpen
filter = ImageFilter.Kernel ((3, 3),
filter = ImageFilter.Kernel((3, 3),
(-1, -1, -1,
-1, 16, -1,
-1, -1, -1))
im = im.filter (filter)
im = im.filter(filter)

# write back again
im.save (sys.argv[2])
im.save(sys.argv[2])

0 comments on commit 2b82e53

Please sign in to comment.