Skip to content

Instantly share code, notes, and snippets.

@skarfacegc
Created April 29, 2012 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skarfacegc/2552554 to your computer and use it in GitHub Desktop.
Save skarfacegc/2552554 to your computer and use it in GitHub Desktop.
Handles tweening images when you've got too many to do at once
#!/opt/local/bin/perl
#
# Handles tweening via imagemagick
#
use Data::Dumper;
my @files = <*>;
my $work_queue = [];
my $i = 0;
my $k = 0;
foreach $file (@files)
{
next unless($file =~ /jpg/i);
# add these things in batches of 25
if($i == 25)
{
# add the current file to the end of the work queue
# we want to makek sure we're tweening between edges
push(@{$work_queue->[$k]}, $file);
$i = 0;
$k++;
}
$i++;
push(@{$work_queue->[$k]}, $file);
}
my $j;
foreach my $work_set (@{$work_queue})
{
my $work_string = join(" ", @$work_set);
system("convert -verbose $work_string -morph 2 /Volumes/Other/tmp/my$j-%05d.jpg");
$j++;
}

This is fairly specific to my use, the 10 batch may not be really well optimized.

First run is still running so this may not actually work. :) I'll update with changes if needed.

Update: 5 frames seemed a bit much. Also trying in a 100 batch (issue with doing all at once is file descriptors)

Update2: 100 was still a bit slow (loads all 100 images in ram, then does the math, then dumps images) Running at 25 images appears to have less churn than 10, but doesn't kill the box when doing the math. Also moving to a 2 tween, initial test render looks promising.

End result: http://www.youtube.com/watch?v=qkfAyRyeln4#!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment