Commit 27a42c16c790edb8d5998c541b7c271665359f61

Authored by Jay Berkenbilt
1 parent b0f15643

Change default decode level to "none" with --json-output

job.sums
@@ -8,10 +8,10 @@ include/qpdf/auto_job_c_pages.hh b3cc0f21029f6d89efa043dcdbfa183cb59325b6506001c @@ -8,10 +8,10 @@ include/qpdf/auto_job_c_pages.hh b3cc0f21029f6d89efa043dcdbfa183cb59325b6506001c
8 include/qpdf/auto_job_c_uo.hh ae21b69a1efa9333050f4833d465f6daff87e5b38e5106e49bbef5d4132e4ed1 8 include/qpdf/auto_job_c_uo.hh ae21b69a1efa9333050f4833d465f6daff87e5b38e5106e49bbef5d4132e4ed1
9 job.yml 3b2b3c6f92b48f6c76109711cbfdd74669fa31a80cd17379548b09f8e76be05d 9 job.yml 3b2b3c6f92b48f6c76109711cbfdd74669fa31a80cd17379548b09f8e76be05d
10 libqpdf/qpdf/auto_job_decl.hh 74df4d7fdbdf51ecd0d58ce1e9844bb5525b9adac5a45f7c9a787ecdda2868df 10 libqpdf/qpdf/auto_job_decl.hh 74df4d7fdbdf51ecd0d58ce1e9844bb5525b9adac5a45f7c9a787ecdda2868df
11 -libqpdf/qpdf/auto_job_help.hh 3ea60a392421150bec5e95ddaad31a82fba1d65c2686d5dfddc920aba1bf5552 11 +libqpdf/qpdf/auto_job_help.hh c1cc99f6fe17285ee5e40730f6280e37d17da1a5f408086ce34e01af121df7ad
12 libqpdf/qpdf/auto_job_init.hh 7ea8e0641dc26fdfba6e283e14dbbff0c016654e174cdace8054f8bef53750fd 12 libqpdf/qpdf/auto_job_init.hh 7ea8e0641dc26fdfba6e283e14dbbff0c016654e174cdace8054f8bef53750fd
13 libqpdf/qpdf/auto_job_json_decl.hh 06caa46eaf71db8a50c046f91866baa8087745a9474319fb7c86d92634cc8297 13 libqpdf/qpdf/auto_job_json_decl.hh 06caa46eaf71db8a50c046f91866baa8087745a9474319fb7c86d92634cc8297
14 libqpdf/qpdf/auto_job_json_init.hh 5f6b53e3c81d4b54ce5c4cf9c3f52d0c02f987c53bf8841c0280367bad23e335 14 libqpdf/qpdf/auto_job_json_init.hh 5f6b53e3c81d4b54ce5c4cf9c3f52d0c02f987c53bf8841c0280367bad23e335
15 libqpdf/qpdf/auto_job_schema.hh 9d543cd4a43eafffc2c4b8a6fee29e399c271c52cb6f7d417ae5497b3c1127dc 15 libqpdf/qpdf/auto_job_schema.hh 9d543cd4a43eafffc2c4b8a6fee29e399c271c52cb6f7d417ae5497b3c1127dc
16 manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580 16 manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580
17 -manual/cli.rst 174cf35e3ce5452701d74c87570604e19587cc41bfa3f6d239b62c2989720bdf 17 +manual/cli.rst e7c35f8183d015d7fe074e38baed4c89bad827fd9c23b4cafd73d562df82ab1b
libqpdf/QPDFJob_config.cc
@@ -308,6 +308,9 @@ QPDFJob::Config::jsonOutput(std::string const& parameter) @@ -308,6 +308,9 @@ QPDFJob::Config::jsonOutput(std::string const& parameter)
308 // explicit use of --json-stream-data. 308 // explicit use of --json-stream-data.
309 o.m->json_stream_data = qpdf_sj_inline; 309 o.m->json_stream_data = qpdf_sj_inline;
310 } 310 }
  311 + if (!o.m->decode_level_set) {
  312 + o.m->decode_level = qpdf_dl_none;
  313 + }
311 return this; 314 return this;
312 } 315 }
313 316
libqpdf/qpdf/auto_job_help.hh
@@ -188,7 +188,7 @@ ap.addOptionHelp("--decode-level", "transformation", "control which streams to u @@ -188,7 +188,7 @@ ap.addOptionHelp("--decode-level", "transformation", "control which streams to u
188 188
189 When uncompressing streams, control which types of compression 189 When uncompressing streams, control which types of compression
190 schemes should be uncompressed: 190 schemes should be uncompressed:
191 -- none: don't uncompress anything 191 +- none: don't uncompress anything. This is the default with --json-output.
192 - generalized: uncompress streams compressed with a 192 - generalized: uncompress streams compressed with a
193 general-purpose compression algorithm. This is the default. 193 general-purpose compression algorithm. This is the default.
194 - specialized: in addition to generalized, also uncompress 194 - specialized: in addition to generalized, also uncompress
@@ -836,8 +836,8 @@ ap.addOptionHelp("--json-output", "json", "serialize to JSON", R"(--json-output[ @@ -836,8 +836,8 @@ ap.addOptionHelp("--json-output", "json", "serialize to JSON", R"(--json-output[
836 836
837 The output file will be qpdf JSON format at the given version. 837 The output file will be qpdf JSON format at the given version.
838 "version" may be a specific version or "latest" (the default). 838 "version" may be a specific version or "latest" (the default).
839 -Version 1 is not supported. See also --json-stream-data  
840 -and --json-stream-prefix. 839 +Version 1 is not supported. See also --json-stream-data,
  840 +--json-stream-prefix, and --decode-level.
841 )"); 841 )");
842 ap.addOptionHelp("--json-input", "json", "input file is qpdf JSON", R"(Treat the input file as a JSON file in qpdf JSON format as 842 ap.addOptionHelp("--json-input", "json", "input file is qpdf JSON", R"(Treat the input file as a JSON file in qpdf JSON format as
843 written by qpdf --json-output. See the "QPDF JSON Format" 843 written by qpdf --json-output. See the "QPDF JSON Format"
manual/cli.rst
@@ -852,7 +852,7 @@ Related Options @@ -852,7 +852,7 @@ Related Options
852 852
853 When uncompressing streams, control which types of compression 853 When uncompressing streams, control which types of compression
854 schemes should be uncompressed: 854 schemes should be uncompressed:
855 - - none: don't uncompress anything 855 + - none: don't uncompress anything. This is the default with --json-output.
856 - generalized: uncompress streams compressed with a 856 - generalized: uncompress streams compressed with a
857 general-purpose compression algorithm. This is the default. 857 general-purpose compression algorithm. This is the default.
858 - specialized: in addition to generalized, also uncompress 858 - specialized: in addition to generalized, also uncompress
@@ -867,14 +867,15 @@ Related Options @@ -867,14 +867,15 @@ Related Options
867 867
868 The following values for :samp:`{parameter}` are available: 868 The following values for :samp:`{parameter}` are available:
869 869
870 - - :samp:`none`: do not attempt to decode any streams 870 + - :samp:`none`: do not attempt to decode any streams. This is the
  871 + default with :qpdf:ref:`--json-output`.
871 872
872 - :samp:`generalized`: decode streams filtered with supported 873 - :samp:`generalized`: decode streams filtered with supported
873 generalized filters: ``/LZWDecode``, ``/FlateDecode``, 874 generalized filters: ``/LZWDecode``, ``/FlateDecode``,
874 ``/ASCII85Decode``, and ``/ASCIIHexDecode``. We define 875 ``/ASCII85Decode``, and ``/ASCIIHexDecode``. We define
875 generalized filters as those to be used for general-purpose 876 generalized filters as those to be used for general-purpose
876 compression or encoding, as opposed to filters specifically 877 compression or encoding, as opposed to filters specifically
877 - designed for image data. 878 + designed for image data. This is the default.
878 879
879 - :samp:`specialized`: in addition to generalized, decode streams 880 - :samp:`specialized`: in addition to generalized, decode streams
880 with supported non-lossy specialized filters; currently this is 881 with supported non-lossy specialized filters; currently this is
@@ -896,7 +897,9 @@ Related Options @@ -896,7 +897,9 @@ Related Options
896 qpdf will recompress streams with generalized filters using flate 897 qpdf will recompress streams with generalized filters using flate
897 compression, effectively eliminating LZW and ASCII-based filters. 898 compression, effectively eliminating LZW and ASCII-based filters.
898 This is usually desirable behavior but can be disabled with 899 This is usually desirable behavior but can be disabled with
899 - ``--decode-level=none``. 900 + ``--decode-level=none``. Note that ``--decode-level=node`` is the
  901 + default when :qpdf:ref:`--json-output` is specified, but it can be
  902 + overridden in that case as well.
900 903
901 As a special case, streams already compressed with ``/FlateDecode`` 904 As a special case, streams already compressed with ``/FlateDecode``
902 are not uncompressed and recompressed. You can change this behavior 905 are not uncompressed and recompressed. You can change this behavior
@@ -3264,13 +3267,18 @@ Related Options @@ -3264,13 +3267,18 @@ Related Options
3264 3267
3265 The output file will be qpdf JSON format at the given version. 3268 The output file will be qpdf JSON format at the given version.
3266 "version" may be a specific version or "latest" (the default). 3269 "version" may be a specific version or "latest" (the default).
3267 - Version 1 is not supported. See also --json-stream-data  
3268 - and --json-stream-prefix. 3270 + Version 1 is not supported. See also --json-stream-data,
  3271 + --json-stream-prefix, and --decode-level.
3269 3272
3270 The output file will be qpdf JSON format at the given version. 3273 The output file will be qpdf JSON format at the given version.
3271 ``version`` may be a specific version or ``latest`` (the default). 3274 ``version`` may be a specific version or ``latest`` (the default).
3272 Version 1 is not supported. See also :qpdf:ref:`--json-stream-data` 3275 Version 1 is not supported. See also :qpdf:ref:`--json-stream-data`
3273 - and :qpdf:ref:`--json-stream-prefix`. 3276 + and :qpdf:ref:`--json-stream-prefix`. The default decode level is
  3277 + ``none``, but you can override it with :qpdf:ref:`--decode-level`.
  3278 + If you want to look at the contents of streams easily as you would
  3279 + in QDF mode (see :ref:`qdf`), you can use
  3280 + ``--decode-level=generalized`` and ``--json-stream-data=file`` for
  3281 + a convenient way to do that.
3274 3282
3275 .. qpdf:option:: --json-input 3283 .. qpdf:option:: --json-input
3276 3284
qpdf/qtest/json.test
@@ -69,7 +69,7 @@ foreach my $d (@json_files) @@ -69,7 +69,7 @@ foreach my $d (@json_files)
69 69
70 $td->runtest("bad json stream data (inline)", 70 $td->runtest("bad json stream data (inline)",
71 {$td->COMMAND => 71 {$td->COMMAND =>
72 - "qpdf --json-output=2" . 72 + "qpdf --json-output=2 --decode-level=all" .
73 " --json-stream-data=inline bad-data.pdf a.json"}, 73 " --json-stream-data=inline bad-data.pdf a.json"},
74 {$td->FILE => "bad-data-json.out", $td->EXIT_STATUS => 3}, 74 {$td->FILE => "bad-data-json.out", $td->EXIT_STATUS => 3},
75 $td->NORMALIZE_NEWLINES); 75 $td->NORMALIZE_NEWLINES);
@@ -79,7 +79,7 @@ $td->runtest("check (inline)", @@ -79,7 +79,7 @@ $td->runtest("check (inline)",
79 $td->NORMALIZE_NEWLINES); 79 $td->NORMALIZE_NEWLINES);
80 $td->runtest("bad json stream data (file)", 80 $td->runtest("bad json stream data (file)",
81 {$td->COMMAND => 81 {$td->COMMAND =>
82 - "qpdf --json-output=2 " . 82 + "qpdf --json-output=2 --decode-level=all" .
83 " --json-stream-data=file --json-stream-prefix=auto" . 83 " --json-stream-data=file --json-stream-prefix=auto" .
84 " bad-data.pdf a.json"}, 84 " bad-data.pdf a.json"},
85 {$td->FILE => "bad-data-json.out", $td->EXIT_STATUS => 3}, 85 {$td->FILE => "bad-data-json.out", $td->EXIT_STATUS => 3},
qpdf/qtest/qpdf-json.test
@@ -71,15 +71,14 @@ foreach my $i (@goodfiles) @@ -71,15 +71,14 @@ foreach my $i (@goodfiles)
71 } 71 }
72 # explicit "latest" as --json-output version 72 # explicit "latest" as --json-output version
73 $td->runtest("good: $f -> JSON", 73 $td->runtest("good: $f -> JSON",
74 - {$td->COMMAND => "qpdf $xargs --decode-level=none" . 74 + {$td->COMMAND => "qpdf $xargs" .
75 " --json-output=latest $f a.json"}, 75 " --json-output=latest $f a.json"},
76 {$td->STRING => "", $td->EXIT_STATUS => 0}, 76 {$td->STRING => "", $td->EXIT_STATUS => 0},
77 $td->NORMALIZE_NEWLINES); 77 $td->NORMALIZE_NEWLINES);
78 # default --json-output version 78 # default --json-output version
79 $td->runtest("good: $f JSON -> JSON", 79 $td->runtest("good: $f JSON -> JSON",
80 {$td->COMMAND => 80 {$td->COMMAND =>
81 - "qpdf --decode-level=none" .  
82 - " --json-input --json-output a.json b.json"}, 81 + "qpdf --json-input --json-output a.json b.json"},
83 {$td->STRING => "", $td->EXIT_STATUS => 0}, 82 {$td->STRING => "", $td->EXIT_STATUS => 0},
84 $td->NORMALIZE_NEWLINES); 83 $td->NORMALIZE_NEWLINES);
85 $td->runtest("good: $f JSON -> QDF", 84 $td->runtest("good: $f JSON -> QDF",