Mercurial > 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 wrap: on
line diff
--- a/resize-gd.c Sat Jun 14 19:14:27 2008 +0200 +++ b/resize-gd.c Sun Jun 15 15:50:59 2008 +0200 @@ -118,7 +118,7 @@ /* parse width and height */ sizeopt.w = atoi(argv[1]); - c = strstr(argv[1], "x"); + c = strchr(argv[1], 'x'); if (c && c[1] != '\0') { sizeopt.h = atoi(c + 1); } else { @@ -130,12 +130,13 @@ for (i = 2; i < argc; i++) { /* printf("processing file '%s'\n", argv[i]); */ - if (strcmp(argv[i]+strlen(argv[i])-4, ".png") == 0) { + c = strrchr(argv[i], '.'); + if (strcmp(c, ".png") == 0 || strcmp(c, ".PNG") == 0) { type = Png; - } else if (strcmp(argv[i]+strlen(argv[i])-4, ".jpg") == 0) { + } else if (strcmp(c, ".jpg") == 0 || strcmp(c, ".JPG") == 0 || strcmp(c, ".jpeg") == 0 || strcmp(c, ".JPEG") == 0) { type = Jpg; } else { - fprintf(stderr, "'%s' has unknown filetype. Filename must end with (lowercase) '.png' or '.jpg'.\n", argv[i]); + fprintf(stderr, "'%s' has unknown filetype. Filename must end with '.jpg', '.jpeg' or '.png'.\n", argv[i]); continue; }