PIL 与 Python-GD 的裁剪和调整大小对比
我正在创建自定义图像,稍后将其转换为 Seadragon AJAX 的图像金字塔。图像和图像金字塔是使用 PIL 创建的。目前需要几个小时才能生成大约 100 张图片的图像和图像金字塔,这些图片的宽度和高度之和约为 32,000,000 x 1000(是的,图像非常长且窄)。性能与我尝试过的另一种算法大致相似(即 deepzoom.py)。我计划看看 python-gd 是否会表现得更好,因为它的大部分功能都是用 C 编码的(来自 GD 库)。我认为性能会显着提高,但我很想听听其他人的意见。特别是 PIL(使用 Image.ANTIALIAS)中的调整大小和裁剪速度很慢。如果我使用 Python-GD,这会显着改善吗?
预先感谢您的意见和建议。
编辑:PIL 和 python-GD 之间的性能差异似乎很小。我将重构我的代码以减少性能瓶颈并包括对多个处理器的支持。我已经测试了 python 'multiprocessing' 模块。结果令人鼓舞。
I am creating custom images that I later convert to an image pyramid for Seadragon AJAX. The images and image pyramid are created using PIL. It currently take a few hours to generate the images and image pyramid for approximately 100 pictures that have a combined width and height of about 32,000,000 by 1000 (yes, the image is very long and narrow). The performance is roughly similar another algorithm I have tried (i.e. deepzoom.py). I plan to see if python-gd would perform better due to most of its functionality being coded in C (from the GD library). I would assume a significant performance increase however I am curious to hear the opinion of others. In particular the resizing and cropping is slow in PIL (w/ Image.ANTIALIAS). Will this improve considerable if I use Python-GD?
Thanks in advance for the comments and suggestions.
EDIT: The performance difference between PIL and python-GD seems minimal. I will refactor my code to reduce performance bottlenecks and include support for multiple processors. I've tested out the python 'multiprocessing' module. Results are encouraging.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
PIL主要是C语言。
抗锯齿速度很慢。关闭抗锯齿功能后,速度会发生什么变化?
PIL is mostly in C.
Antialiasing is slow. When you turn off antialiasing, what happens to the speed?
VIPS 包含快速的 deepzoom 创建器。我对
deepzoom.py
进行了计时,在我的机器上我看到:其中
wtc.jpg
是 10,000 x 10,000 像素 RGB JPG 图像,而wtc.py
> 正在使用这些设置。VIPS 的速度大约是原来的三倍,但需要四分之一的内存:
我不知道为什么 sys 的速度要高得多。
VIPS includes a fast deepzoom creator. I timed
deepzoom.py
and on my machine I see:where
wtc.jpg
is a 10,000 x 10,000 pixel RGB JPG image, andwtc.py
is using these settings.VIPS is around three times faster and needs a quarter of the memory:
I'm not sure why sys is so much higher.