Thursday, October 22, 2015

Real-time Resizing of Flickr Images Using GPUs

Archie Russell:

The selection of sizes has grown semi-organically over the years, and all told, we serve eleven different resizes per photo which, in sum, use nearly as much storage as the original photo. Almost 90% of this storage is held in the handful of resizes 640px and larger, so we targeted our efforts at eliminating some of these sizes.


Instead we took on a pretty ambitious goal: maintain our largest resize, usually 2048px wide, as a source image and create any other moderate or large-sized resizes on-the-fly from this source, without sacrificing image quality or significantly affecting performance. Using the original uploaded photo as a resize source image was impractical, as these can be very large and exist in a variety of formats.


Our resize daemons transfer JPEGs from shared memory to GPU device memory. Once here, the real image processing takes place. The JPEGs are decoded, cropped, sharpened, resized, re-sharpened as needed, re-encoded as JPEGs, and finally transferred back to shared memory. From shared memory, our Apache module returns the resized JPEG to the caller.


With significant optimization, this code is able to resize our 2048px JPEGs to 1600px in under 16ms. This is more than 15x faster than GraphicsMagick and nearly 10x faster than Ymagine.

3 Comments RSS · Twitter

Donald Perreault

Is this something anyone can do with a good video card? For instance I changed out the original card in my Mid 2010 MacPro with an AMD Radeon HD 7950 with 3gb. Is it possible for me to offload to the GPU on my Radeon?


@Donald Not sure about resizing, but I think Mac OS X already uses the video card to display JPEGs.

[…] Previously: Real-time Resizing of Flickr Images Using GPUs. […]

Leave a Comment