ITeye博客

python 和 php-gd图片处理性能对比

tailorcai · 2011-09-06 13:48 · Web前端 · Markdown

python + PIL


#coding=utf-8

import PIL
from PIL import Image
import time

start = time.time()
im = Image.open("sample.jpg")
im1 = im.resize((100,100), Image.ANTIALIAS)
im1.save( '/tmp/sample_py.jpg')
print time.time() - start

python2.7 pil.py 0.0170481204987 python2.7 pil.py 0.0169599056244

PHP + GD


<?PHP
$start = microtime();
$image = imagecreatefromjpeg('sample.jpg');
$image_p = imagecreatetruecolor(100,100);

imagecopyresampled($image_p, $image, 0, 0, 0, 0, 100, 100, imagesx($image), imagesy($image));

imagejpeg( $image_p ,'/tmp/sample_php.jpg',80);

print_r( microtime() - $start );

0.009451 0.009427

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。