-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultigif.pl
More file actions
executable file
·38 lines (31 loc) · 839 Bytes
/
multigif.pl
File metadata and controls
executable file
·38 lines (31 loc) · 839 Bytes
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
31
32
33
34
35
36
37
38
#!/usr/bin/perl
#
# multigif - convert a gif to webp and webm
#
# Requires imagemagick and ffmpeg on the PATH.
#
use strict;
use warnings;
my $numArgs = $#ARGV + 1;
if ($numArgs != 1) {
die("need exactly one command line argument - the filename of the GIF to convert.\n")
}
my $filename = shift;
if ($filename !~ /\.gif$/) {
die("invalid file extension: '$filename', expected .gif\n")
}
if (!-f $filename) {
die("file not found: '$filename'\n")
}
my @outputFormats = ("webp", "webm");
foreach (@outputFormats) {
convert($filename, $_)
}
sub convert {
my $inputFilename = shift;
my $outputFormat = shift;
my $basename = $inputFilename =~ s/^(.*)\.gif/$1/r;
my $outputFilename = sprintf("%s.%s", $basename, $outputFormat);
my $cmd = "magick $inputFilename -coalesce $outputFilename";
`$cmd`;
}