diff options
author | Simon McVittie <smcv@debian.org> | 2017-09-28 11:19:27 +0100 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2017-09-28 11:19:27 +0100 |
commit | 30b101e6e8ffa5d02af9b44bfb9abdc2f2a84547 (patch) | |
tree | 381cfb4d5e33c0b2977ccb6ea7a4c057a672d854 | |
parent | 54dc5217ed1c55a49fd4a279de2a7bd2294684ca (diff) | |
parent | 146f1d9ab546ffc4aebef79340c6691720513f46 (diff) | |
download | ikiwiki-30b101e6e8ffa5d02af9b44bfb9abdc2f2a84547.tar ikiwiki-30b101e6e8ffa5d02af9b44bfb9abdc2f2a84547.tar.gz |
Merge remote-tracking branch 'tails/img-determinism'
-rw-r--r-- | IkiWiki/Plugin/img.pm | 6 | ||||
-rwxr-xr-x | t/img.t | 13 |
2 files changed, 19 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index 740c44f96..79cfba20f 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -174,6 +174,12 @@ sub preprocess (@) { my $r = $im->Read("$format:$srcfile\[$pagenumber]"); error sprintf(gettext("failed to read %s: %s"), $file, $r) if $r; + if ($config{deterministic}) { + $im->Set('date:create' => 0); + $im->Set('date:modify' => 0); + $im->Set('option' => 'png:exclude-chunk=time'); + } + if (! defined $im->Get("width") || ! defined $im->Get("height")) { error sprintf(gettext("failed to get dimensions of %s"), $file); } @@ -155,6 +155,19 @@ ok(! -e "$outpath/666x-really-pdf.jpg"); like($outhtml, qr/${quot}really-pdf\.png${quot} does not seem to be a valid png file/); ok(! -e "$outpath/666x-really-pdf.png"); +# resize is deterministic when deterministic=1 +ok(utime(333333333, 333333333, "t/tmp/in/redsquare.png")); +ok(! system("rm $outpath/10x-redsquare.png")); +ok(! system(@command, '--set-yaml', 'img_allowed_formats=[JPEG, PNG, svg, pdf]', '--set', 'deterministic=1', "--rebuild")); +ok(! system("cp $outpath/10x-redsquare.png $outpath/10x-redsquare.png.orig")); +ok(utime(444444444, 444444444, "t/tmp/in/redsquare.png")); +ok(! system("rm $outpath/10x-redsquare.png")); +ok(! system(@command, '--set-yaml', 'img_allowed_formats=[JPEG, PNG, svg, pdf]', '--set', 'deterministic=1', "--rebuild")); +ok( + ! system("cmp $outpath/10x-redsquare.png $outpath/10x-redsquare.png.orig"), + "resize is deterministic when configured with deterministic=1" +); + # disable support for uncommon formats and try again ok(! system(@command, "--rebuild")); ok(! -e "$outpath/10x-bluesquare.png"); |