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

This commit is contained in:
Jay Berkenbilt 2022-05-21 17:51:34 -04:00
parent b0f1564376
commit 27a42c16c7
6 changed files with 27 additions and 17 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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"

View File

@ -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

View File

@ -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},

View File

@ -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",