/* * imgsz - print width & height sizes of images as HTML format * * Filename: imgsz.c * Version: 0.4 * Author: itouh * Time-stamp: * Copyright (c) 2003 Itou Hiroki */ #define PROGNAME "imgsz" #define PROGVERSION "0.4" #include #include #include /* strrchr() */ #include #define GIFHEAD 32 //10 byte (sig(6)+width(2)+height(2)) is enough #define PNGHEAD 32 //24 byte (sig(8)+IHDRlen(4)+type(4)+width(4)+height(4)) is enough #define XBMHEAD 100 //?? #define MAXLINECHAR 1024 #define errret {free(src); size.width=-1; return size;} /* * global variable */ const char *g_suffix[] = { ".gif", ".jpg", ".png", ".xbm" }; char g_exifdate[MAXLINECHAR]; char g_exifmaker[MAXLINECHAR]; char g_exifmodel[MAXLINECHAR]; /* * struct */ typedef struct{ long width; long height; } size_type; typedef enum {gif, jpg, png, xbm, notype} imagetype; /* * prototype */ int getSuffix(char *fname); size_type jpgGetSize(char *fname); size_type gifGetSize(char *fname); size_type pngGetSize(char *fname); size_type xbmGetSize(char *fname); void getExifInfo(unsigned char *exiftop); void getExifData(unsigned char *dst, unsigned char *p, unsigned char *exiftop, int bigEndian); unsigned short big2ltls(void *v); unsigned long big2ltll(void *v); /***********************************************************************/ int main(int argc, char *argv[]){ int i; int ratio = 1; int exif = 0; /* * print help & exit */ if(argc<=1){ printf("%s version %s - print width & height sizes of images as HTML format\n" "usage: %s