Mercurial > resize-gd
comparison 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 |
comparison
equal
deleted
inserted
replaced
13:c4834b4f4b54 | 14:6f5c3a02e4d5 |
---|---|
116 exit(2); | 116 exit(2); |
117 } | 117 } |
118 | 118 |
119 /* parse width and height */ | 119 /* parse width and height */ |
120 sizeopt.w = atoi(argv[1]); | 120 sizeopt.w = atoi(argv[1]); |
121 c = strstr(argv[1], "x"); | 121 c = strchr(argv[1], 'x'); |
122 if (c && c[1] != '\0') { | 122 if (c && c[1] != '\0') { |
123 sizeopt.h = atoi(c + 1); | 123 sizeopt.h = atoi(c + 1); |
124 } else { | 124 } else { |
125 sizeopt.h = -1; /* keep aspect ratio */ | 125 sizeopt.h = -1; /* keep aspect ratio */ |
126 } | 126 } |
128 | 128 |
129 /* process images */ | 129 /* process images */ |
130 for (i = 2; i < argc; i++) { | 130 for (i = 2; i < argc; i++) { |
131 /* printf("processing file '%s'\n", argv[i]); */ | 131 /* printf("processing file '%s'\n", argv[i]); */ |
132 | 132 |
133 if (strcmp(argv[i]+strlen(argv[i])-4, ".png") == 0) { | 133 c = strrchr(argv[i], '.'); |
134 if (strcmp(c, ".png") == 0 || strcmp(c, ".PNG") == 0) { | |
134 type = Png; | 135 type = Png; |
135 } else if (strcmp(argv[i]+strlen(argv[i])-4, ".jpg") == 0) { | 136 } else if (strcmp(c, ".jpg") == 0 || strcmp(c, ".JPG") == 0 || strcmp(c, ".jpeg") == 0 || strcmp(c, ".JPEG") == 0) { |
136 type = Jpg; | 137 type = Jpg; |
137 } else { | 138 } else { |
138 fprintf(stderr, "'%s' has unknown filetype. Filename must end with (lowercase) '.png' or '.jpg'.\n", argv[i]); | 139 fprintf(stderr, "'%s' has unknown filetype. Filename must end with '.jpg', '.jpeg' or '.png'.\n", argv[i]); |
139 continue; | 140 continue; |
140 } | 141 } |
141 | 142 |
142 /* load image */ | 143 /* load image */ |
143 in = fopen(argv[i], "rb"); | 144 in = fopen(argv[i], "rb"); |