---
title: "python 和 php-gd图片处理性能对比"
author: "tailorcai"
date: "2011-09-06T13:48:15Z"
tags: []
categories: ["Web前端"]
slug: "python-php-gd"
draft: false
lastmod: "2011-09-06T13:48:15Z"
id: 1166577
url: "https://tailorcai.iteye.com/blog/1166577"
---

python + PIL

```java

#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


```java

<?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
>