ref: 246505fd73f229f252b2ad368006ce234a09b7b9
parent: 362445ced69525d1556b72de5c078b87eed56625
author: giles <giles@ded80894-8fb9-0310-811b-c03f3676ab4d>
date: Wed Apr 2 11:12:17 EST 2003
Try to set the output format based on the extension given in -o if any. Also fixes a bug where the format was undefined with -o. (yay valgrind!) git-svn-id: http://svn.ghostscript.com/jbig2dec/trunk@231 ded80894-8fb9-0310-811b-c03f3676ab4d
--- a/jbig2dec.c
+++ b/jbig2dec.c
@@ -368,7 +368,8 @@
params.verbose = 1;
params.hash = 0;
params.output_file = NULL;
-
+ params.output_format = jbig2dec_format_none;
+
filearg = parse_options(argc, argv, ¶ms);
if (params.hash) hash_init(¶ms);
@@ -467,8 +468,13 @@
params.output_file = make_output_filename(argv[filearg], ".pbm");
params.output_format = jbig2dec_format_pbm;
#endif
+ } else {
+ int len = strlen(params.output_file);
+ if ((len >= 3) && (params.output_format == jbig2dec_format_none))
+ /* try to set the output type by the given extension */
+ set_output_format(¶ms, params.output_file + len - 3);
}
-
+
/* retrieve and write out all the completed pages */
while ((image = jbig2_page_out(ctx)) != NULL) {
write_page_image(¶ms, image);