resize-gd
diff resize-gd.c @ 14:6f5c3a02e4d5
filename suffix is now detected in lower or upper case letters
author | meillo@marmaro.de |
---|---|
date | Sun, 15 Jun 2008 15:50:59 +0200 |
parents | 6b8e8fcd6d4d |
children | c50716420346 |
line diff
1.1 --- a/resize-gd.c Sat Jun 14 19:14:27 2008 +0200 1.2 +++ b/resize-gd.c Sun Jun 15 15:50:59 2008 +0200 1.3 @@ -118,7 +118,7 @@ 1.4 1.5 /* parse width and height */ 1.6 sizeopt.w = atoi(argv[1]); 1.7 - c = strstr(argv[1], "x"); 1.8 + c = strchr(argv[1], 'x'); 1.9 if (c && c[1] != '\0') { 1.10 sizeopt.h = atoi(c + 1); 1.11 } else { 1.12 @@ -130,12 +130,13 @@ 1.13 for (i = 2; i < argc; i++) { 1.14 /* printf("processing file '%s'\n", argv[i]); */ 1.15 1.16 - if (strcmp(argv[i]+strlen(argv[i])-4, ".png") == 0) { 1.17 + c = strrchr(argv[i], '.'); 1.18 + if (strcmp(c, ".png") == 0 || strcmp(c, ".PNG") == 0) { 1.19 type = Png; 1.20 - } else if (strcmp(argv[i]+strlen(argv[i])-4, ".jpg") == 0) { 1.21 + } else if (strcmp(c, ".jpg") == 0 || strcmp(c, ".JPG") == 0 || strcmp(c, ".jpeg") == 0 || strcmp(c, ".JPEG") == 0) { 1.22 type = Jpg; 1.23 } else { 1.24 - fprintf(stderr, "'%s' has unknown filetype. Filename must end with (lowercase) '.png' or '.jpg'.\n", argv[i]); 1.25 + fprintf(stderr, "'%s' has unknown filetype. Filename must end with '.jpg', '.jpeg' or '.png'.\n", argv[i]); 1.26 continue; 1.27 } 1.28