There’s a common misconception that you can’t use shared hosting for interesting tasks like image and video processing. But at WebFaction we say au contraire; today we’re taking a look at the image processing tools available on our servers.

For starters, let’s take ImageMagick for test drive. ImageMagick is a library and collection of command line tools for working with bitmap images. Here it is on web310:

$ convert -version
Version: ImageMagick 6.5.4-7 2012-05-07 Q16 OpenMP http://www.imagemagick.org
Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC

ImageMagick has a broad range of capabilities, from resizing an image to creating animations. Here’s an example of converting the WebFaction logo from one type to another:

$ convert -quality 50 webfaction-logo.png webfaction-logo.jpg

ImageMagick is handy to have around, but if you’re working with Python, you might prefer to use PIL, the Python Imaging Library. Like ImageMagick, PIL provides a variety of ways to manipulate images. Here’s an example of resizing an image with PIL (on web310):

$ python2.7
Python 2.7.3 (default, May 18 2012, 14:51:16)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Image
>>> im = Image.open("webfaction-logo.png")
>>> small = im.resize((130, 30))
>>> small.save("webfaction-logo-small.png")

Still images are nice, but it doesn’t hurt to add some motion and sound every now and then. FFmpeg provides a number of tools and libraries for working with video and audio. Here’s an example of converting a Quicktime video from a point-and-shoot camera to a web-friendly MP4:

$ ffmpeg -v 0 -i short_clip.mov short_clip.mp4
FFmpeg version UNKNOWN, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --enable-gpl --enable-libamr-nb --enable-libamr-wb --enable-   libfaac --enable-libfaad --enable-libmp3lame --enable-nonfree
  libavutil     49.14. 0 / 49.14. 0
  libavcodec    52.15. 0 / 52.15. 0
  libavformat   52.28. 0 / 52.28. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  built on Sep 13 2011 08:22:01, gcc: 4.4.4 20100726 (Red Hat 4.4.4-13)
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
Press [q] to stop encoding
frame=  224 fps= 50 q=31.0 Lsize=    1301kB time=7.38 bitrate=1443.7kbits/s
video:1239kB audio:57kB global headers:0kB muxing overhead 0.414617%

And, as we’ve mentioned previously, you can build other great image and video tools in your home directory. What are you doing with images and video? Let us know in the comments. If you have any questions, join us on the Q&A Community.