comparison resize-gd.c @ 15:c50716420346 0.2

new exit code (4) if all files failed in resizing
author meillo@marmaro.de
date Mon, 23 Jun 2008 21:03:05 +0200
parents 6f5c3a02e4d5
children 159402d54c29
comparison
equal deleted inserted replaced
14:6f5c3a02e4d5 15:c50716420346
87 87
88 int 88 int
89 main(int argc, char* argv[]) { 89 main(int argc, char* argv[]) {
90 int i; 90 int i;
91 int type; 91 int type;
92 int success = 0;
92 gdImagePtr im_in; 93 gdImagePtr im_in;
93 gdImagePtr im_out; 94 gdImagePtr im_out;
94 FILE* in; 95 FILE* in;
95 FILE* out; 96 FILE* out;
96 char* c; 97 char* c;
162 sizeimg.h = im_in->sy; 163 sizeimg.h = im_in->sy;
163 sizedest = calcsize(sizeopt, sizeimg, 0); 164 sizedest = calcsize(sizeopt, sizeimg, 0);
164 165
165 /* skip images that dont need to be resized */ 166 /* skip images that dont need to be resized */
166 if (sizedest.w == sizeimg.w && sizedest.h == sizeimg.h) { 167 if (sizedest.w == sizeimg.w && sizedest.h == sizeimg.h) {
168 success++;
167 gdImageDestroy(im_in); 169 gdImageDestroy(im_in);
168 continue; 170 continue;
169 } 171 }
170 172
171 /* copy-resize the image */ 173 /* copy-resize the image */
187 } else if (type == Jpg) { 189 } else if (type == Jpg) {
188 gdImageJpeg(im_out, out, -1); 190 gdImageJpeg(im_out, out, -1);
189 } 191 }
190 fclose(out); 192 fclose(out);
191 193
194 success++;
195
192 gdImageDestroy(im_in); 196 gdImageDestroy(im_in);
193 gdImageDestroy(im_out); 197 gdImageDestroy(im_out);
194 } 198 }
195 199
196 return 0; 200 if (success == 0) {
197 } 201 return 4; /* no resizing was successful */
202 } else {
203 return 0;
204 }
205 }