I'm setting up a web app in which people will upload images. Once uploaded the images will be watermarked then resized multiple times (Thumbnails, different sizes etc.) and finally uploaded to Amazon S3 for storage.

The web app is written in Python with the Tornado framework, I don't really want to lock up the Tornado threads with the image processing so I'm going to send it out to a seperate script (and possibly even seperate servers) using Gearman (I've developed an async-gearman client for Python/Tornado).

One of the advantages of Gearman is that it's possible to launch jobs in multiple languages, so the actual processing and uploading of the image could be done in ether Python, Ruby, PHP, Perl, Java, C, or something else.

This leaves the question, is one better for the job? Are there certain libraries only available for specific languages that are especially good at image resizing? The most important thing will be performance: we'd like to be able to run as many jobs on a server as possible. Are there other factors I should be looking at?

I'd prefer to stick with Python, Ruby, or PHP because that's what I'm familiar with but if the performance gain from doing it in Java/C is good enough I'd be okay with implementing it like that.

I'm not looking for code examples, I can find those myself, but I'd like to know if there are any big differences between the image processing libraries. I know PHP probably has the easiest to use wit GD, and I've used a couple of the Python libraries before and they seem okay. I've never done anything with images in Ruby.

  • You can resize images on client side too. For instance: plupload.com/index.php
    – Karolis
    Commented Sep 7, 2011 at 10:34
  • @Karolis Not reliably enough, anyone can fake data sent to the server. With tools like Firebug you can even modify Javascript etc. so our users could edit the code that resizes the images for the thumbnails and every image size would be full resolution. Also the only upload implementations we have is HTML5 or forms for HTML4 so we'd need server-side resizing for HTML4. Add to that, most people using the site will be uploading lots of images at once, we don't want to crash out peoples browsers.
    – Blank
    Commented Sep 7, 2011 at 10:40
  • 8
    I believe that all of the scripting languages would just provide interfaces to external libraries. If that's true - I don't think there would be any significant performance gain in using one language instead of another.
    – Narf
    Commented Sep 7, 2011 at 10:42
  • @samarudge I understand that client side implementation may not be suitable for one or the other reason. But I disagree with the argument about fake data. All user input should always be checked at the server side. Images are not an exception. Fake data sent by users should be discarded.
    – Karolis
    Commented Sep 7, 2011 at 10:53
  • @Narf Yep, for example PHP's GD lib is written in C
    – feeela
    Commented Sep 7, 2011 at 11:38

1 Answer 1


I think there are many libraries in many languages to do this, and they all work pretty well.

What you probably should be looking for though is just an image processor for the platform you host your application on. This will be the most efficient and most supported method.

ImageMagick is just one of many examples. Many third party hosting companies have this already installed and available for applications as well.

  • We don't use a hosting company, we're on co-located servers so we have full admin. All the Python image libraries (I've seen) are blocking and getting them to work asynchronously with our Tornado servers would probably be more effort than required. We'll also probably end up with dedicated image processing servers so we'll need Gearman for that anyway.
    – Blank
    Commented Sep 7, 2011 at 16:12
  • I think you will find ImageMagick using either a ruby or php api will suit you well then. There should be installers for that for the operating system you are on. You can even call it from shell scripts etc. if you need to batch process files already on the file system. Commented Sep 7, 2011 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.