Group: How is it done?


GIF-Animation mit ImageMagick


Thomas Arend aka Byggvir
17 Dec 2008 - 310 visits- Permalink   |   Translate title into English

Eine kleine GIF Spielerei, die leider nur mit dem Original funktioniert, weil die anderen Größen nach jpg konvertiert werden.


Wie es gemacht wurde?


Mit einem kleinen Programm Zufallszahlen für die Rechteck erzeugt, daraus s/w Masken mit ImageMagic erstellt. Die einzelnen Masken über das Original gelegt, und die Einzelbilder zur GIF-Animation zusammengefügt.


Also etwa folgende Schritte

C-Programm für die Zufallszahlen


#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

int main(int argc, char *argv[ ]) {
int zahl , anzahl, i , j;
int max[256];

if (argc > 1 ) {
anzahl = atoi(argv[1]);
for (j=2;j<argc;j++) {
max[j-2]=atoi(argv[j]);
}
}
else {
anzahl = 1;
}

srand(time(NULL));
for (i=0;i<anzahl; i++ ) {
for (j=0;j<argc-2;j++) {
zahl = rand() % max[j];
printf("%d ", zahl);
}
printf("\n");
}

}



Script zur Maskenerzeugung


#!/bin/sh

DRAW=""
W=1200
H=800
J=0
read x y w h r g b
while [ $x ]
do
DRAW=" -fill white -draw 'rectangle ${x},${y} $((x+w+300)),$((y+h+300))'"
echo convert -size ${W}x${H} xc:black $DRAW fenster-`printf %4.4d $J`.png
read x y w h r g b
J=$((J+1))
done

Befehle an der Unix-Shell



zufallszahl 10 300 200 140 100 | fenster | sh
for B in fenster*.png; do convert -composite -compose multiply $B back.jpg x-$B; done
convert -delay 100 x-*.png -loop 0 x.gif

You must be a member of this group to reply to this topic. (Join?)