| 50 | | my $retcode = save_execute( |
|---|
| 51 | | "$conf->{focr_bin_gifsicle} -o $tfile2 --unoptimize $tfile #$index", |
|---|
| 52 | | undef, |
|---|
| 53 | | undef, |
|---|
| 54 | | ">>$efile"); |
|---|
| 55 | | return $tfile2 if ($retcode == 0); |
|---|
| | 50 | if ($index >=0) { |
|---|
| | 51 | my $retcode = |
|---|
| | 52 | save_execute( |
|---|
| | 53 | "$conf->{focr_bin_gifsicle} -o $tfile2 --unoptimize $tfile #$index", |
|---|
| | 54 | undef, |
|---|
| | 55 | undef, |
|---|
| | 56 | ">>$efile"); |
|---|
| | 57 | return $tfile2 if ($retcode == 0); |
|---|
| | 58 | } |
|---|
| | 59 | else { |
|---|
| | 60 | # Explode the animation into GIFs |
|---|
| | 61 | my $retcode = |
|---|
| | 62 | save_execute( |
|---|
| | 63 | "$conf->{focr_bin_gifsicle} -e -o $tfile2 $tfile", |
|---|
| | 64 | undef, |
|---|
| | 65 | undef, |
|---|
| | 66 | ">>$efile"); |
|---|
| | 67 | if ($retcode != 0) { |
|---|
| | 68 | warnlog("$conf->{focr_bin_gifsicle}: cannot explode $tfile"); |
|---|
| | 69 | return $tfile; |
|---|
| | 70 | } |
|---|
| | 71 | my $delays=$info->{'delays'}; |
|---|
| | 72 | my $imagecount=@$delays; |
|---|
| | 73 | |
|---|
| | 74 | for (my $i=0; $i<$imagecount; $i++) { |
|---|
| | 75 | # change all GIF frames to pnm |
|---|
| | 76 | my $ffile=sprintf "%s.%03d", $tfile2, $i; |
|---|
| | 77 | my $retcode = |
|---|
| | 78 | save_execute( |
|---|
| | 79 | "$conf->{focr_bin_giftopnm} $ffile", |
|---|
| | 80 | undef, |
|---|
| | 81 | ">$ffile.pnm", |
|---|
| | 82 | ">>$efile"); |
|---|
| | 83 | if ($retcode != 0) { |
|---|
| | 84 | warnlog("$conf->{focr_bin_gifsicle}: cannot explode $tfile"); |
|---|
| | 85 | return $tfile; |
|---|
| | 86 | } |
|---|
| | 87 | } |
|---|
| | 88 | my $cmd="$conf->{focr_bin_pnmcat} -topbottom "; |
|---|
| | 89 | my $cfile="$imgdir/pnmcat"; |
|---|
| | 90 | for (my $i=0; $i<$imagecount; $i++) { |
|---|
| | 91 | # concat pnm frames |
|---|
| | 92 | my $ffile=sprintf "%s.%03d.pnm", $tfile2, $i; |
|---|
| | 93 | $cmd.=" $ffile"; |
|---|
| | 94 | } |
|---|
| | 95 | $retcode = |
|---|
| | 96 | save_execute( |
|---|
| | 97 | $cmd, |
|---|
| | 98 | undef, |
|---|
| | 99 | ">$cfile.pnm", |
|---|
| | 100 | ">>$efile"); |
|---|
| | 101 | if ($retcode != 0) { |
|---|
| | 102 | warnlog("$conf->{focr_bin_pnmcat}: cannot contact frames of $tfile"); |
|---|
| | 103 | return $tfile; |
|---|
| | 104 | } |
|---|
| | 105 | $retcode = |
|---|
| | 106 | save_execute( |
|---|
| | 107 | "$conf->{focr_bin_ppmtogif} $cfile.pnm", |
|---|
| | 108 | undef, |
|---|
| | 109 | ">$cfile.gif", |
|---|
| | 110 | ">>$efile"); |
|---|
| | 111 | if ($retcode != 0) { |
|---|
| | 112 | warnlog("$conf->{focr_bin_ppmtogif}: cannot convert to GIF $cfile.pnm"); |
|---|
| | 113 | return $tfile; |
|---|
| | 114 | } |
|---|
| | 115 | return "$cfile.gif"; |
|---|
| | 116 | } |
|---|