resize-gd

changeset 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 c4834b4f4b54
children c50716420346
files resize-gd.1 resize-gd.c
diffstat 2 files changed, 7 insertions(+), 6 deletions(-) [+]
line diff
     1.1 --- a/resize-gd.1	Sat Jun 14 19:14:27 2008 +0200
     1.2 +++ b/resize-gd.1	Sun Jun 15 15:50:59 2008 +0200
     1.3 @@ -1,4 +1,4 @@
     1.4 -.TH RESIZE\-GD 1 "resize\-gd\-0.1" "2008\-06\-14" "resize\-gd"
     1.5 +.TH RESIZE\-GD 1 "resize\-gd\-0.2" "2008\-06\-15" "resize\-gd"
     1.6  
     1.7  .SH NAME
     1.8  resize\-gd \- resizes images using the gd library
     1.9 @@ -15,7 +15,7 @@
    1.10  .PP
    1.11  If <width>x<height> ist given, the images are resized to match that dimensions. The images probably get stretched and enlarged.
    1.12  .PP
    1.13 -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).
    1.14 +Only JPEG and PNG files are supported. The filetype is detected by the filename suffix which has to be `.jpg', `.jpeg' or `.png'.
    1.15  Unsupported files get skipped.
    1.16  .PP
    1.17  This program is meant to be a small(er) alternative to the
     2.1 --- a/resize-gd.c	Sat Jun 14 19:14:27 2008 +0200
     2.2 +++ b/resize-gd.c	Sun Jun 15 15:50:59 2008 +0200
     2.3 @@ -118,7 +118,7 @@
     2.4  
     2.5  	/* parse width and height */
     2.6  	sizeopt.w = atoi(argv[1]);
     2.7 -	c = strstr(argv[1], "x");
     2.8 +	c = strchr(argv[1], 'x');
     2.9  	if (c && c[1] != '\0') {
    2.10  		sizeopt.h = atoi(c + 1);
    2.11  	} else {
    2.12 @@ -130,12 +130,13 @@
    2.13  	for (i = 2; i < argc; i++) {
    2.14  		/* printf("processing file '%s'\n", argv[i]); */
    2.15  
    2.16 -		if (strcmp(argv[i]+strlen(argv[i])-4, ".png") == 0) {
    2.17 +		c = strrchr(argv[i], '.');
    2.18 +		if (strcmp(c, ".png") == 0 || strcmp(c, ".PNG") == 0) {
    2.19  			type = Png;
    2.20 -		} else if (strcmp(argv[i]+strlen(argv[i])-4, ".jpg") == 0) {
    2.21 +		} else if (strcmp(c, ".jpg") == 0 || strcmp(c, ".JPG") == 0 || strcmp(c, ".jpeg") == 0 || strcmp(c, ".JPEG") == 0) {
    2.22  			type = Jpg;
    2.23  		} else {
    2.24 -			fprintf(stderr, "'%s' has unknown filetype. Filename must end with (lowercase) '.png' or '.jpg'.\n", argv[i]);
    2.25 +			fprintf(stderr, "'%s' has unknown filetype. Filename must end with '.jpg', '.jpeg' or '.png'.\n", argv[i]);
    2.26  			continue;
    2.27  		}
    2.28