X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=OSX%2Fupdate-thumbnail.pl;h=da95f4aea3f1b2398461240cbc4f09d25400cd0f;hb=d5186197bc394e10a4402f7f6d23fbb14103bc50;hp=407cc8f2fe351ac283f71c725c52177612b6a516;hpb=b81f521c5ad7022ac12db18ca8fcdd9fb063831e;p=xscreensaver diff --git a/OSX/update-thumbnail.pl b/OSX/update-thumbnail.pl index 407cc8f2..da95f4ae 100755 --- a/OSX/update-thumbnail.pl +++ b/OSX/update-thumbnail.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# Copyright © 2006-2012 Jamie Zawinski +# Copyright © 2006-2014 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that @@ -18,10 +18,12 @@ require 5; use strict; my $progname = $0; $progname =~ s@.*/@@g; -my $version = q{ $Revision: 1.1 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/; +my ($version) = ('$Revision: 1.4 $' =~ m/\s(\d[.\d]+)\s/s); my $verbose = 1; +$ENV{PATH} = "/opt/local/bin:$ENV{PATH}"; # MacPorts, for ImageMagick + sub safe_system(@) { my @cmd = @_; @@ -90,9 +92,12 @@ sub update($$) { rand(0xFFFFFFFF)); my @cmd = ("convert", $img, + "-strip", "-resize", $size . "^", "-gravity", "center", "-extent", $size, + "-quality", "95", # saves 8% + "+dither", "-colors", "128", # Saves an additional 61% $tmp); print STDERR "$progname: exec: " . join(' ', @cmd) . "\n" @@ -104,6 +109,17 @@ sub update($$) { error ("failed: " . join(" ", @cmd)); } + # This only saves 0.4% on top of the above. + # @cmd = ("optipng", "-quiet", "-o7", $tmp); + # print STDERR "$progname: exec: " . join(' ', @cmd) . "\n" + # if ($verbose > 2); + # safe_system (@cmd); + + if (! -s $tmp) { + unlink $tmp; + error ("failed: " . join(" ", @cmd)); + } + if (! cmp_files ($tmp, $target)) { unlink $tmp; print STDERR "$progname: $target: unchanged\n" if ($verbose > 1);