Skip to content

Instantly share code, notes, and snippets.

@s-wool
Created December 1, 2013 08:38
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 s-wool/7729926 to your computer and use it in GitHub Desktop.
Save s-wool/7729926 to your computer and use it in GitHub Desktop.
convert skype emoticons to animated gif file
#!/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;
}
@BenjaminVanRyseghem
Copy link

I tried this script today and I have some errors.
Since I am a PERL newbie, maybe it comes from me 😄

Use of uninitialized value $height in division (/) at ./emoji.pl line 23.
Usage: i_writegif_wiol(IO,hashref, images...) at /Library/Perl/5.16/darwin-thread-multi-2level/Imager/File/GIF.pm line 84.

Any pointer?
Thanks

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