mirror of
https://github.com/qpdf/qpdf.git
synced 2024-09-21 17:49:08 +00:00
f6b13fcc05
The sample file (nested-images.pdf) includes a pdf with an image that is nested within an XObject within an XObject in the Resources dict of the only page. These images were ignored in prior versions of qpdf.
63 lines
2.1 KiB
Perl
63 lines
2.1 KiB
Perl
#!/usr/bin/env perl
|
|
require 5.008;
|
|
use warnings;
|
|
use strict;
|
|
|
|
unshift(@INC, '.');
|
|
require qpdf_test_helpers;
|
|
|
|
chdir("qpdf") or die "chdir testdir failed: $!\n";
|
|
|
|
require TestDriver;
|
|
|
|
cleanup();
|
|
|
|
my $td = new TestDriver('image-optimization');
|
|
|
|
my @image_opt = (
|
|
['image-streams', 'image-streams', ''],
|
|
['small-images', 'defaults', ''],
|
|
['small-images', 'min-width',
|
|
'--oi-min-width=150 --oi-min-height=0 --oi-min-area=0'],
|
|
['small-images', 'min-height',
|
|
'--oi-min-width=0 --oi-min-height=150 --oi-min-area=0'],
|
|
['small-images', 'min-area',
|
|
'--oi-min-width=0 --oi-min-height=0 --oi-min-area=30000'],
|
|
['small-images', 'min-area-all',
|
|
'--oi-min-width=0 --oi-min-height=0 --oi-min-area=30000'],
|
|
['large-inline-image', 'inline-images',
|
|
'--ii-min-bytes=0'],
|
|
['large-inline-image', 'inline-images-all-size',
|
|
'--oi-min-width=0 --oi-min-height=0 --oi-min-area=0 --ii-min-bytes=0'],
|
|
['large-inline-image', 'inline-images-keep-some', ''],
|
|
['large-inline-image', 'inline-images-keep-all', '--keep-inline-images'],
|
|
['unsupported-optimization', 'unsupported',
|
|
'--oi-min-width=0 --oi-min-height=0 --oi-min-area=0'],
|
|
['nested-images', 'nested-images',
|
|
'--oi-min-width=0 --oi-min-height=0 --oi-min-area=0']
|
|
);
|
|
|
|
my $n_tests = 2 * scalar(@image_opt);
|
|
|
|
foreach my $d (@image_opt)
|
|
{
|
|
my ($f, $description, $args) = @$d;
|
|
|
|
$td->runtest("optimize images: $description",
|
|
{$td->COMMAND =>
|
|
"qpdf --static-id --optimize-images --verbose" .
|
|
" $args $f.pdf a.pdf",
|
|
$td->FILTER => "perl filter-optimize-images.pl"},
|
|
{$td->FILE => "optimize-images-$description.out",
|
|
$td->EXIT_STATUS => 0},
|
|
$td->NORMALIZE_NEWLINES);
|
|
$td->runtest("check json: $description",
|
|
{$td->COMMAND => "qpdf --json --json-key=pages a.pdf"},
|
|
{$td->FILE => "optimize-images-$description-json.out",
|
|
$td->EXIT_STATUS => 0},
|
|
$td->NORMALIZE_NEWLINES);
|
|
}
|
|
|
|
cleanup();
|
|
$td->report($n_tests);
|