aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-05-21 23:51:34 +0200
committerJay Berkenbilt <ejb@ql.org>2022-05-21 23:51:34 +0200
commit27a42c16c790edb8d5998c541b7c271665359f61 (patch)
treeb6a9e6dac3f6f8a03603c7ae2341da8b2b997a5a
parentb0f1564376ce847a4a6b6aa54d71bbf6f60ef4c9 (diff)
downloadqpdf-27a42c16c790edb8d5998c541b7c271665359f61.tar.zst
Change default decode level to "none" with --json-output
-rw-r--r--job.sums4
-rw-r--r--libqpdf/QPDFJob_config.cc3
-rw-r--r--libqpdf/qpdf/auto_job_help.hh6
-rw-r--r--manual/cli.rst22
-rw-r--r--qpdf/qtest/json.test4
-rw-r--r--qpdf/qtest/qpdf-json.test5
6 files changed, 27 insertions, 17 deletions
diff --git a/job.sums b/job.sums
index 63801a83..befae830 100644
--- a/job.sums
+++ b/job.sums
@@ -8,10 +8,10 @@ include/qpdf/auto_job_c_pages.hh b3cc0f21029f6d89efa043dcdbfa183cb59325b6506001c
include/qpdf/auto_job_c_uo.hh ae21b69a1efa9333050f4833d465f6daff87e5b38e5106e49bbef5d4132e4ed1
job.yml 3b2b3c6f92b48f6c76109711cbfdd74669fa31a80cd17379548b09f8e76be05d
libqpdf/qpdf/auto_job_decl.hh 74df4d7fdbdf51ecd0d58ce1e9844bb5525b9adac5a45f7c9a787ecdda2868df
-libqpdf/qpdf/auto_job_help.hh 3ea60a392421150bec5e95ddaad31a82fba1d65c2686d5dfddc920aba1bf5552
+libqpdf/qpdf/auto_job_help.hh c1cc99f6fe17285ee5e40730f6280e37d17da1a5f408086ce34e01af121df7ad
libqpdf/qpdf/auto_job_init.hh 7ea8e0641dc26fdfba6e283e14dbbff0c016654e174cdace8054f8bef53750fd
libqpdf/qpdf/auto_job_json_decl.hh 06caa46eaf71db8a50c046f91866baa8087745a9474319fb7c86d92634cc8297
libqpdf/qpdf/auto_job_json_init.hh 5f6b53e3c81d4b54ce5c4cf9c3f52d0c02f987c53bf8841c0280367bad23e335
libqpdf/qpdf/auto_job_schema.hh 9d543cd4a43eafffc2c4b8a6fee29e399c271c52cb6f7d417ae5497b3c1127dc
manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580
-manual/cli.rst 174cf35e3ce5452701d74c87570604e19587cc41bfa3f6d239b62c2989720bdf
+manual/cli.rst e7c35f8183d015d7fe074e38baed4c89bad827fd9c23b4cafd73d562df82ab1b
diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc
index 6b72103b..5a343f79 100644
--- a/libqpdf/QPDFJob_config.cc
+++ b/libqpdf/QPDFJob_config.cc
@@ -308,6 +308,9 @@ QPDFJob::Config::jsonOutput(std::string const& parameter)
// explicit use of --json-stream-data.
o.m->json_stream_data = qpdf_sj_inline;
}
+ if (!o.m->decode_level_set) {
+ o.m->decode_level = qpdf_dl_none;
+ }
return this;
}
diff --git a/libqpdf/qpdf/auto_job_help.hh b/libqpdf/qpdf/auto_job_help.hh
index e4bab551..a933497f 100644
--- a/libqpdf/qpdf/auto_job_help.hh
+++ b/libqpdf/qpdf/auto_job_help.hh
@@ -188,7 +188,7 @@ ap.addOptionHelp("--decode-level", "transformation", "control which streams to u
When uncompressing streams, control which types of compression
schemes should be uncompressed:
-- none: don't uncompress anything
+- none: don't uncompress anything. This is the default with --json-output.
- generalized: uncompress streams compressed with a
general-purpose compression algorithm. This is the default.
- specialized: in addition to generalized, also uncompress
@@ -836,8 +836,8 @@ ap.addOptionHelp("--json-output", "json", "serialize to JSON", R"(--json-output[
The output file will be qpdf JSON format at the given version.
"version" may be a specific version or "latest" (the default).
-Version 1 is not supported. See also --json-stream-data
-and --json-stream-prefix.
+Version 1 is not supported. See also --json-stream-data,
+--json-stream-prefix, and --decode-level.
)");
ap.addOptionHelp("--json-input", "json", "input file is qpdf JSON", R"(Treat the input file as a JSON file in qpdf JSON format as
written by qpdf --json-output. See the "QPDF JSON Format"
diff --git a/manual/cli.rst b/manual/cli.rst
index 2bc829df..c6e408c6 100644
--- a/manual/cli.rst
+++ b/manual/cli.rst
@@ -852,7 +852,7 @@ Related Options
When uncompressing streams, control which types of compression
schemes should be uncompressed:
- - none: don't uncompress anything
+ - none: don't uncompress anything. This is the default with --json-output.
- generalized: uncompress streams compressed with a
general-purpose compression algorithm. This is the default.
- specialized: in addition to generalized, also uncompress
@@ -867,14 +867,15 @@ Related Options
The following values for :samp:`{parameter}` are available:
- - :samp:`none`: do not attempt to decode any streams
+ - :samp:`none`: do not attempt to decode any streams. This is the
+ default with :qpdf:ref:`--json-output`.
- :samp:`generalized`: decode streams filtered with supported
generalized filters: ``/LZWDecode``, ``/FlateDecode``,
``/ASCII85Decode``, and ``/ASCIIHexDecode``. We define
generalized filters as those to be used for general-purpose
compression or encoding, as opposed to filters specifically
- designed for image data.
+ designed for image data. This is the default.
- :samp:`specialized`: in addition to generalized, decode streams
with supported non-lossy specialized filters; currently this is
@@ -896,7 +897,9 @@ Related Options
qpdf will recompress streams with generalized filters using flate
compression, effectively eliminating LZW and ASCII-based filters.
This is usually desirable behavior but can be disabled with
- ``--decode-level=none``.
+ ``--decode-level=none``. Note that ``--decode-level=node`` is the
+ default when :qpdf:ref:`--json-output` is specified, but it can be
+ overridden in that case as well.
As a special case, streams already compressed with ``/FlateDecode``
are not uncompressed and recompressed. You can change this behavior
@@ -3264,13 +3267,18 @@ Related Options
The output file will be qpdf JSON format at the given version.
"version" may be a specific version or "latest" (the default).
- Version 1 is not supported. See also --json-stream-data
- and --json-stream-prefix.
+ Version 1 is not supported. See also --json-stream-data,
+ --json-stream-prefix, and --decode-level.
The output file will be qpdf JSON format at the given version.
``version`` may be a specific version or ``latest`` (the default).
Version 1 is not supported. See also :qpdf:ref:`--json-stream-data`
- and :qpdf:ref:`--json-stream-prefix`.
+ and :qpdf:ref:`--json-stream-prefix`. The default decode level is
+ ``none``, but you can override it with :qpdf:ref:`--decode-level`.
+ If you want to look at the contents of streams easily as you would
+ in QDF mode (see :ref:`qdf`), you can use
+ ``--decode-level=generalized`` and ``--json-stream-data=file`` for
+ a convenient way to do that.
.. qpdf:option:: --json-input
diff --git a/qpdf/qtest/json.test b/qpdf/qtest/json.test
index a013c845..d010496b 100644
--- a/qpdf/qtest/json.test
+++ b/qpdf/qtest/json.test
@@ -69,7 +69,7 @@ foreach my $d (@json_files)
$td->runtest("bad json stream data (inline)",
{$td->COMMAND =>
- "qpdf --json-output=2" .
+ "qpdf --json-output=2 --decode-level=all" .
" --json-stream-data=inline bad-data.pdf a.json"},
{$td->FILE => "bad-data-json.out", $td->EXIT_STATUS => 3},
$td->NORMALIZE_NEWLINES);
@@ -79,7 +79,7 @@ $td->runtest("check (inline)",
$td->NORMALIZE_NEWLINES);
$td->runtest("bad json stream data (file)",
{$td->COMMAND =>
- "qpdf --json-output=2 " .
+ "qpdf --json-output=2 --decode-level=all" .
" --json-stream-data=file --json-stream-prefix=auto" .
" bad-data.pdf a.json"},
{$td->FILE => "bad-data-json.out", $td->EXIT_STATUS => 3},
diff --git a/qpdf/qtest/qpdf-json.test b/qpdf/qtest/qpdf-json.test
index c627da89..23edda2e 100644
--- a/qpdf/qtest/qpdf-json.test
+++ b/qpdf/qtest/qpdf-json.test
@@ -71,15 +71,14 @@ foreach my $i (@goodfiles)
}
# explicit "latest" as --json-output version
$td->runtest("good: $f -> JSON",
- {$td->COMMAND => "qpdf $xargs --decode-level=none" .
+ {$td->COMMAND => "qpdf $xargs" .
" --json-output=latest $f a.json"},
{$td->STRING => "", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
# default --json-output version
$td->runtest("good: $f JSON -> JSON",
{$td->COMMAND =>
- "qpdf --decode-level=none" .
- " --json-input --json-output a.json b.json"},
+ "qpdf --json-input --json-output a.json b.json"},
{$td->STRING => "", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
$td->runtest("good: $f JSON -> QDF",