Cool Apple-Like Photo Animations With POV-Ray, ImageMagick and Solaris

A GIF Animation Showing Popular Sun ProductsOne of the features I like most about Apple's iPhoto application is the transition effect in slideshows where the whole screen becomes a cube that rotates into the next photograph. The same effect is also used when switching users, etc.

Recently we took a team photograph for an internal web page. I wanted that effect and I love the open source raytracer POV-Ray so I wrote a script that renders the same animation effect and creates an animated GIF using ImageMagick. You can see an example output to the right featuring photos of some popular Sun products. BTW, check out photos.sun.com for free, high-quality access to Sun product photography.

To create your own photocubes, you just need POV-Ray and ImageMagick in your path and the photocube.sh script. Being open source, all run on Solaris but also on Linux, NetBSD or any other operating system that can run open source software. I'd love to try this script out on a Niagara 2 system with its 8 cores, 16 pipelines, 64 threads and 8 FPUs. Hmmm, all rendering frames in parallel :).

There are already precompiled distributions of POVRay and ImageMagick on Blastwave that you can install very easily onto your Solaris machine if you don't have them already.

Just call the script with 6 URLs or pathnames. It will then automatically read in the images, render the animation frames and then combine them all into an animated GIF:

-bash-3.00$ ../photocube.sh \*.jpg
Converting images to be quadratic...
Fetching and processing 721_DRIVE-open.1024x768.jpg
Fetching and processing 773_FrtAbv-78L-PWR-FAN.1024x768.jpg
Fetching and processing 915_Lside-plexiOFF.1024x768.jpg
Fetching and processing IMG_4551.1024x768.jpg
Fetching and processing blackbox_wind_turbine.1024x768.jpg
Fetching and processing ultra_cool_combo.1024x768.jpg
Rendering animation frames...
Creating animated gif file...
-bash-3.00$ ls
721_DRIVE-open.1024x768.jpg          blackbox_wind_turbine.1024x768.jpg
773_FrtAbv-78L-PWR-FAN.1024x768.jpg  photocube.gif
915_Lside-plexiOFF.1024x768.jpg      ultra_cool_combo.1024x768.jpg
IMG_4551.1024x768.jpg
-bash-3.00$

The script uses ImageMagick to make the pictures quadratic and to limit their size to 1200x1200 pictures if necessary. Since the -extent switch is fairly new, you'll need to use a newer distribution of ImageMagick, the one on the Solaris Companion CD is sadly not new enough. The POVRay source (embedded in the script) uses an S-curve to turn the cube which produces a natural and smooth acceleration/decelleration effect. It would have been more efficient to let POVRay output PNG files rather than TGA but for some reason some of the PNG files that POVRay produces were not compatible with ImageMagick.

Feel free to modify this script to your needs. You may want to experiment with other ways of animating the cube or other image transition effects. Maybe you want to use ffmpeg to create real video files instead of animated GIFs. Be careful when cranking up the number of frames while using ImageMagick to create animated GIFs, ImageMagick wants to suck in all frames into memory before creating the animated GIF and so you may end up using a lot of memory. If someone has a more elegant, scriptable animated GIF creator, please leave me a comment.

I hope you enjoy this little exercise in raytracing and animation. Let me know if you have suggestions or other ideas to improve this script!

Comments:

Hi,
You forgot to mention you need the curl package from blastwave also.
Apart from that it works great for me:-)

Cheers
Richard.

Posted by Richard Skelton on August 23, 2007 at 06:14 PM CEST #

Hi Richard,
ah yes, thank you for pointing that one out. And thank you for trying it out!
Constantin

Posted by Constantin Gonzalez on August 24, 2007 at 01:19 AM CEST #

Hi Constantin,

I tried the photocube.sh script on my Linux boxes.
First it was missing a "`" in line 57:
if [ "`echo $i | cut -c1" = "/" ]; then
Should be:
if [ "`echo $i | cut -c1`" = "/" ]; then

Then I had an issue with my SuSE 9.3 server caused in an older ImageMagick version (6.1.8) where convert does not know about "-extent" option.

After moving to a openSuSE 10.2 laptop (ImageMagick-6.3.0.0-27.6, povray-3.6.1-36) this all went well.

Thanks for this nice hint.

Regards,
Juergen

Posted by Juergen on September 11, 2007 at 05:08 AM CEST #

Hi Juergen,
thank you for your comment and for pointing out the quote bug. I didn't run into it yet, not sure why. Maybe there's a difference in the way your shell interprets errors in if statements vs. the bash implementation that I normally use on Solaris.

The -extent option is very useful and I admit that I didn't bother trying to implement the size adjustment without it :).

Have fun and let me know about the animations you've created. If I get a couple of nice animations, I might put them up in a later post.

Cheers,
Constantin

Posted by Constantin Gonzalez on September 12, 2007 at 04:47 AM CEST #

Post a Comment:
Comments are closed for this entry.
About

Tune in and find out useful stuff about Sun Solaris, CPU and System Technology, Web 2.0 - and have a little fun, too!

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
Bookmarks
TopEntries
Blogroll
OldTopEntries