# HG changeset patch # User meillo@marmaro.de # Date 1213537859 -7200 # Node ID 6f5c3a02e4d5dc4a029c2a7f387be891abd0baba # Parent c4834b4f4b544693634b6c725d7675c168d7dc22 filename suffix is now detected in lower or upper case letters diff -r c4834b4f4b54 -r 6f5c3a02e4d5 resize-gd.1 --- a/resize-gd.1 Sat Jun 14 19:14:27 2008 +0200 +++ b/resize-gd.1 Sun Jun 15 15:50:59 2008 +0200 @@ -1,4 +1,4 @@ -.TH RESIZE\-GD 1 "resize\-gd\-0.1" "2008\-06\-14" "resize\-gd" +.TH RESIZE\-GD 1 "resize\-gd\-0.2" "2008\-06\-15" "resize\-gd" .SH NAME resize\-gd \- resizes images using the gd library @@ -15,7 +15,7 @@ .PP If x ist given, the images are resized to match that dimensions. The images probably get stretched and enlarged. .PP -Only JPEG and PNG files are supported. The filetype is detected by the filename suffix which has to be either `.jpg' or `.png' (in lowercase letters). +Only JPEG and PNG files are supported. The filetype is detected by the filename suffix which has to be `.jpg', `.jpeg' or `.png'. Unsupported files get skipped. .PP This program is meant to be a small(er) alternative to the diff -r c4834b4f4b54 -r 6f5c3a02e4d5 resize-gd.c --- 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; }