Skip to content

Instantly share code, notes, and snippets.

@niner
Created July 23, 2019 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niner/0f24bdb76080a2bfbc7e5c3f6376b4b0 to your computer and use it in GitHub Desktop.
Save niner/0f24bdb76080a2bfbc7e5c3f6376b4b0 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl6
sub MAIN($file) {
my $warn = run('pngcrush', '-n', '-warn', $file, :err).err.slurp-rest;
if $warn.contains("PCS illuminant is not D50"|"known incorrect sRGB profile"|"iCCP: Not recognizing known sRGB profile that has been edited") {
say "Fixing $file";
my $output = run('pngcrush', '-warn', '-ow', '-rem', 'allb', '-reduce', $file, "$file.tmp", :err).err.slurp-rest;
note $output unless $output eq $warn;
}
elsif $warn {
note "Unknown warning: $warn in $file";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment