Created
December 1, 2013 08:38
-
-
Save s-wool/7729926 to your computer and use it in GitHub Desktop.
convert skype emoticons to animated gif file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Imager; | |
use File::Basename; | |
use constant SIZE => 20; | |
my @emoticons = glob "/Applications/Skype.app/Contents/Resources/*_anim.png"; | |
for my $emoticon (@emoticons) { | |
my $file_name = basename($emoticon); | |
my $emoticon_name = shift [ split /_/, $file_name ]; | |
my @frames; | |
my $img = Imager->new; | |
$img->read(file => $emoticon); | |
my $width = $img->getwidth; | |
my $height = $img->getheight; | |
for my $top (map $_ * SIZE, 0..($height/SIZE)-1) { | |
my $bottom = $top + 20; | |
for my $left (map $_ * SIZE, 0..($width/SIZE)-1) { | |
my $right = $left + SIZE; | |
push @frames, $img->crop( | |
left => $left, | |
right => $right, | |
top => $top, | |
bottom => $bottom, | |
); | |
} | |
} | |
Imager->write_multi({ | |
file => "$emoticon_name.gif", | |
type => 'gif', | |
gif_delay => 5, | |
gif_loop => 0, | |
gif_disposal => 2, | |
}, @frames) or die Imager->errstr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried this script today and I have some errors.
Since I am a PERL newbie, maybe it comes from me 😄
Any pointer?
Thanks