Commits

Ondřej Surý committed 5eef0f8

Don't open and close output file, without PNG or JPEG support

Comments (0)

Files changed (1)

 	}
 	/* TBB: Write img to test/fttest.jpg or test/fttest.png */
 	if (im->trueColor) {
+#ifdef HAVE_LIBJPEG
 		out = fopen ("test/fttest.jpg", "wb");
 		if (!out) {
 			fprintf(stderr, "Can't create test/fttest.jpg\n");
 			exit (1);
 		}
 		/* Fairly high JPEG quality setting */
-#ifdef HAVE_LIBJPEG
 		gdImageJpeg (im, out, 90);
-#else
-		fprintf(stderr, "No JPEG library support.\n");
-#endif
 		fclose (out);
 		fprintf(stderr, "Test image written to test/fttest.jpg\n");
+#else
+		fprintf(stderr, "Test image not written; No JPEG library support.\n");
+#endif
 	} else {
+#ifdef HAVE_LIBPNG
 		out = fopen ("test/fttest.png", "wb");
 		if (!out) {
 			fprintf(stderr, "Can't create test/fttest.png\n");
 			exit (1);
 		}
 		/* 2.0.10: correct ifdef, thanks to Gabriele Verzeletti */
-#ifdef HAVE_LIBPNG
 		gdImagePng (im, out);
-#else
-		fprintf(stderr, "No PNG library support.\n");
-#endif
 		fclose (out);
 		fprintf(stderr, "Test image written to test/fttest.png\n");
+#else
+		fprintf(stderr, "Test image not written; No PNG library support.\n");
+#endif
 	}
 	/* Destroy it */
 	gdImageDestroy (im);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.