Python imaging alternatives

2019-03-09 05:14发布

I have python code that needs to do just a couple simple things to photographs: crop, resize, and overlay a watermark. I've used PIL, and the resample/resize results are TERRIBLE. I've used imagemagick, and the interface and commands were designed by packaging a cat in a box, and then repeatedly throwing it down a set of stairs at a keyboard.

I'm looking for something which is not PIL or Imagemagick that I can use with python to do simple, high-quality image transformations. For that matter, it doesn't even have to have python bindings if the command line interface is good.

Oh, and it needs to be relatively platform agnostic, our production servers are linux, but some of our devs develop on windows. It can't require the installation of a bunch of silly gui code to use as a library, either.

9条回答
Lonely孤独者°
2楼-- · 2019-03-09 05:25

GIMP has a reasonable command-line interface, I think.

查看更多
ら.Afraid
3楼-- · 2019-03-09 05:28

Take a look at some of these imaging libraries:

hxxp://pypi.python.org/pypi/collective.croppingimagefield/0.1beta

hxxp://pypi.python.org/pypi/cropresize/0.1.1

hxxp://pypi.python.org/pypi/image_resize/1.0

查看更多
戒情不戒烟
4楼-- · 2019-03-09 05:31

PIL can do good resizing. Make sure your source image is in RGB mode, not palette colors, and try the different algorithm choices.

查看更多
手持菜刀,她持情操
5楼-- · 2019-03-09 05:34

I've used PIL, and the resample/resize results are TERRIBLE.

They shouldn't be, as long as you:

  1. use only Image.ANTIALIAS filtering for downscaling operations
  2. use only Image.BICUBIC filtering for upscaling operations.
  3. remember to convert to 'RGB' colour mode before the resize if you are using a paletted image
  4. don't use .thumbnail(). it's crap
  5. set the quality= level to something appropriate when saving JPEGs (the default is quite low)
查看更多
爷的心禁止访问
6楼-- · 2019-03-09 05:35

While imagemagick seems to be the de facto open-source imaging library, possibly DevIL (cross platform, seems to do simple image operations) or FreeImage.

查看更多
女痞
7楼-- · 2019-03-09 05:35

I've used PIL, and the resample/resize results are TERRIBLE.

Resizing in PIL was broken in many ways and PIL is not maintained for a long time. Starting from Pillow 2.7 most of the problems are fixed along with dramatically performance improvement. Make sure you are using latest Pillow.

查看更多
登录 后发表回答