Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

migrated from Sep 7 '11 at 12:29

This question came from our site for professional and enthusiast programmers.

You can resize images on client side too. For instance: – Karolis Sep 7 '11 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. – sam Sep 7 '11 at 10:40
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 Sep 7 '11 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 Sep 7 '11 at 10:53
@Narf Yep, for example PHP's GD lib is written in C – feeela Sep 7 '11 at 11:38

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.

share|improve this answer
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. – sam Sep 7 '11 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. – Bill Leeper Sep 7 '11 at 19:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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