créer un site internet




 
 

calculer la taille d'une image gif

Un petit bout de code ( encore !!) pour obtenir la taille d'une image gif.
#include <stdio.h>

int main (int argc, char *argv[])
{
char buf[7];
FILE *in, *out;
unsigned char w=0,h=0,w1=0,h1=0;

        if ( argc < 2 ) { printf("gif_info <filename>\n"); exit(0);}

        if((in = fopen(argv[1],"rb"))== NULL){
                printf("impossible a ouvrir: \n",argv[1]);
                exit(0);
        }

        fread(buf,1,6,in); buf[6] = 0x00;
        fread(&w,1,1,in);
        fread(&w1,1,1,in);
        fread(&h,1,1,in);
        fread(&h1,1,1,in);

        if ( ! strncmp(buf,"GIF89a",6) || ! strncmp(buf,"GIF87a",6))
           printf("%s %s width=\"%d\" height=\"%d\"\n",argv[1],
              buf,w+256*w1,h+256*h1);
        else
          printf("%s : Erreur de format %s\n", argv[1], buf);
        fclose(in);
}


A propos - Contact - Réalisé avec Youhp3 v3.8 - v7.0 béta
Mentions Légales - CNIL n°800914
© AffilZEN 1998 - 2008 :: Auteur Nicolas : CV - Ingénieur web - NiKoZEN : Référencement

Alphazen, partenaire shopping : Code reduction - Code reduction
Part. : Créer un site, Creer son site