X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=OSX%2Fupdate-thumbnail.pl;h=1f5eccee7c3c56f75d0ca49a97a0f6d697bbf3c7;hb=2762a7d7cf8d83e68b8f635941f6609119d630ae;hp=407cc8f2fe351ac283f71c725c52177612b6a516;hpb=b81f521c5ad7022ac12db18ca8fcdd9fb063831e;p=xscreensaver diff --git a/OSX/update-thumbnail.pl b/OSX/update-thumbnail.pl index 407cc8f2..1f5eccee 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-2013 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 = q{ $Revision: 1.3 $ }; $version =~ s/^[^0-9]+([0-9.]+).*$/$1/; my $verbose = 1; +$ENV{PATH} = "/opt/local/bin:$ENV{PATH}"; # MacPorts, for ImageMagick + sub safe_system(@) { my @cmd = @_; @@ -93,6 +95,8 @@ sub update($$) { "-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 +108,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);